semian 0.19.1 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/semian/extconf.rb +2 -0
- data/ext/semian/resource.c +1 -7
- data/lib/semian/activerecord_trilogy_adapter.rb +7 -17
- data/lib/semian/mysql2.rb +4 -8
- data/lib/semian/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf43c5c57553b9262a1c1c4ef782fe92483480c1793604c9d0c7b328b907de53
|
4
|
+
data.tar.gz: c8d73c47247f10cdac57053356f61e65bdb5f38c134b2122f030e42dc175b26d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6c96130e5c56f963e7ab63f1d561c843a8d3ff93593981bfe819d034dcf3c3e88a4a3a00b35c8779b8529629ea8fa29cd06e73acec0233ec1b909bd32184057
|
7
|
+
data.tar.gz: 589794eedc49e355705f82271743346a289f10aba2089d80a89a9eade0fa4a221d5476142e3c20aee3a501139ceb6c82217bed378842e6f91cc6f5cb54fc5636
|
data/ext/semian/extconf.rb
CHANGED
data/ext/semian/resource.c
CHANGED
@@ -359,12 +359,6 @@ ms_to_timespec(long ms, struct timespec *ts)
|
|
359
359
|
ts->tv_nsec = (ms % 1000) * 1000000;
|
360
360
|
}
|
361
361
|
|
362
|
-
static void
|
363
|
-
semian_resource_mark(void *ptr)
|
364
|
-
{
|
365
|
-
/* noop */
|
366
|
-
}
|
367
|
-
|
368
362
|
static void
|
369
363
|
semian_resource_free(void *ptr)
|
370
364
|
{
|
@@ -386,7 +380,7 @@ static const rb_data_type_t
|
|
386
380
|
semian_resource_type = {
|
387
381
|
"semian_resource",
|
388
382
|
{
|
389
|
-
|
383
|
+
NULL,
|
390
384
|
semian_resource_free,
|
391
385
|
semian_resource_memsize
|
392
386
|
},
|
@@ -9,7 +9,7 @@ module ActiveRecord
|
|
9
9
|
class TrilogyAdapter
|
10
10
|
ActiveRecord::ActiveRecordError.include(::Semian::AdapterError)
|
11
11
|
|
12
|
-
class SemianError <
|
12
|
+
class SemianError < ConnectionNotEstablished
|
13
13
|
def initialize(semian_identifier, *args)
|
14
14
|
super(*args)
|
15
15
|
@semian_identifier = semian_identifier
|
@@ -82,26 +82,16 @@ module Semian
|
|
82
82
|
|
83
83
|
private
|
84
84
|
|
85
|
-
def acquire_semian_resource(**)
|
86
|
-
super
|
87
|
-
rescue ActiveRecord::StatementInvalid => error
|
88
|
-
if error.cause.is_a?(Trilogy::TimeoutError)
|
89
|
-
semian_resource.mark_failed(error)
|
90
|
-
error.semian_identifier = semian_identifier
|
91
|
-
end
|
92
|
-
raise
|
93
|
-
end
|
94
|
-
|
95
85
|
def resource_exceptions
|
96
|
-
[
|
86
|
+
[
|
87
|
+
ActiveRecord::AdapterTimeout,
|
88
|
+
ActiveRecord::ConnectionFailed,
|
89
|
+
ActiveRecord::ConnectionNotEstablished,
|
90
|
+
]
|
97
91
|
end
|
98
92
|
|
99
93
|
# TODO: share this with Mysql2
|
100
|
-
QUERY_ALLOWLIST =
|
101
|
-
%r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i,
|
102
|
-
%r{\A(?:/\*.*?\*/)?\s*COMMIT}i,
|
103
|
-
%r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i,
|
104
|
-
)
|
94
|
+
QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i
|
105
95
|
|
106
96
|
def query_allowlisted?(sql, *)
|
107
97
|
QUERY_ALLOWLIST.match?(sql)
|
data/lib/semian/mysql2.rb
CHANGED
@@ -22,8 +22,8 @@ module Semian
|
|
22
22
|
include Semian::Adapter
|
23
23
|
|
24
24
|
CONNECTION_ERROR = Regexp.union(
|
25
|
-
/Can't connect to MySQL server on/i,
|
26
|
-
/Lost connection to MySQL server/i,
|
25
|
+
/Can't connect to (?:MySQL )?server on/i,
|
26
|
+
/Lost connection to (?:MySQL )?server/i,
|
27
27
|
/MySQL server has gone away/i,
|
28
28
|
/Too many connections/i,
|
29
29
|
/closed MySQL connection/i,
|
@@ -37,11 +37,7 @@ module Semian
|
|
37
37
|
DEFAULT_HOST = "localhost"
|
38
38
|
DEFAULT_PORT = 3306
|
39
39
|
|
40
|
-
|
41
|
-
%r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i,
|
42
|
-
%r{\A(?:/\*.*?\*/)?\s*COMMIT}i,
|
43
|
-
%r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i,
|
44
|
-
)
|
40
|
+
QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i
|
45
41
|
|
46
42
|
class << self
|
47
43
|
# The naked methods are exposed as `raw_query` and `raw_connect` for instrumentation purpose
|
@@ -114,7 +110,7 @@ module Semian
|
|
114
110
|
end
|
115
111
|
|
116
112
|
def query_whitelisted?(sql, *)
|
117
|
-
|
113
|
+
QUERY_ALLOWLIST =~ sql
|
118
114
|
rescue ArgumentError
|
119
115
|
# The above regexp match can fail if the input SQL string contains binary
|
120
116
|
# data that is not recognized as a valid encoding, in which case we just
|
data/lib/semian/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Francis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-27 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: |2
|
16
16
|
A Ruby C extention that is used to control access to shared resources
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.4.
|
82
|
+
rubygems_version: 3.4.21
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Bulkheading for Ruby with SysV semaphores
|