with_advisory_lock 7.0.2 → 7.6.0
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/.github/workflows/ci.yml +28 -0
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +28 -1
- data/Gemfile +9 -4
- data/README.md +61 -4
- data/bin/setup_test_db +8 -6
- data/docker-compose.yml +10 -0
- data/lib/with_advisory_lock/concern.rb +5 -5
- data/lib/with_advisory_lock/core_advisory.rb +14 -10
- data/lib/with_advisory_lock/mysql_advisory.rb +31 -19
- data/lib/with_advisory_lock/postgresql_advisory.rb +96 -29
- data/lib/with_advisory_lock/version.rb +1 -1
- data/test/dummy/app/models/trilogy_label.rb +5 -0
- data/test/dummy/app/models/trilogy_record.rb +6 -0
- data/test/dummy/app/models/trilogy_tag.rb +10 -0
- data/test/dummy/app/models/trilogy_tag_audit.rb +5 -0
- data/test/dummy/config/application.rb +11 -0
- data/test/dummy/config/database.yml +8 -0
- data/test/dummy/db/trilogy_schema.rb +15 -0
- data/test/dummy/lib/tasks/db.rake +18 -26
- data/test/sanity_check_test.rb +48 -1
- data/test/test_helper.rb +10 -1
- data/test/with_advisory_lock/blocking_test.rb +267 -0
- data/test/with_advisory_lock/concern_test.rb +10 -0
- data/test/with_advisory_lock/lock_test.rb +53 -6
- data/test/with_advisory_lock/multi_adapter_test.rb +76 -2
- data/test/with_advisory_lock/parallelism_test.rb +10 -0
- data/test/with_advisory_lock/shared_test.rb +28 -3
- data/test/with_advisory_lock/thread_test.rb +10 -0
- data/test/with_advisory_lock/transaction_test.rb +38 -8
- data/with_advisory_lock.gemspec +1 -24
- metadata +12 -32
- data/.ruby-version +0 -2
- data/.tool-versions +0 -1
|
@@ -97,9 +97,6 @@ class PostgreSQLSharedLocksTest < GemTestCase
|
|
|
97
97
|
two.cleanup!
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
test 'allows shared lock to be upgraded to an exclusive lock' do
|
|
101
|
-
skip 'PostgreSQL lock visibility issue - locks acquired via advisory lock methods not showing in pg_locks'
|
|
102
|
-
end
|
|
103
100
|
end
|
|
104
101
|
|
|
105
102
|
class MySQLSharedLocksTest < GemTestCase
|
|
@@ -127,3 +124,31 @@ class MySQLSharedLocksTest < GemTestCase
|
|
|
127
124
|
assert_match(/shared locks are not supported/, exception.message)
|
|
128
125
|
end
|
|
129
126
|
end
|
|
127
|
+
|
|
128
|
+
if GemTestCase.trilogy_available?
|
|
129
|
+
class TrilogySharedLocksTest < GemTestCase
|
|
130
|
+
self.use_transactional_tests = false
|
|
131
|
+
|
|
132
|
+
test 'does not allow two exclusive locks' do
|
|
133
|
+
one = SharedTestWorker.new(TrilogyTag, false)
|
|
134
|
+
assert_predicate(one, :locked?)
|
|
135
|
+
|
|
136
|
+
two = SharedTestWorker.new(TrilogyTag, false)
|
|
137
|
+
refute(two.locked?)
|
|
138
|
+
|
|
139
|
+
one.cleanup!
|
|
140
|
+
two.cleanup!
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
test 'raises an error when attempting to use a shared lock' do
|
|
144
|
+
one = SharedTestWorker.new(TrilogyTag, true)
|
|
145
|
+
assert_equal(false, one.locked?)
|
|
146
|
+
|
|
147
|
+
exception = assert_raises(ArgumentError) do
|
|
148
|
+
one.cleanup!
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
assert_match(/shared locks are not supported/, exception.message)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -12,10 +12,6 @@ class PostgreSQLTransactionScopingTest < GemTestCase
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
test 'session locks release after the block executes' do
|
|
16
|
-
skip 'PostgreSQL lock visibility issue - locks acquired via advisory lock methods not showing in pg_locks'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
15
|
test 'session locks release when transaction fails inside block' do
|
|
20
16
|
Tag.transaction do
|
|
21
17
|
assert_equal(0, @pg_lock_count.call)
|
|
@@ -31,10 +27,6 @@ class PostgreSQLTransactionScopingTest < GemTestCase
|
|
|
31
27
|
end
|
|
32
28
|
end
|
|
33
29
|
|
|
34
|
-
test 'transaction level locks hold until the transaction completes' do
|
|
35
|
-
skip 'PostgreSQL lock visibility issue - locks acquired via advisory lock methods not showing in pg_locks'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
30
|
test 'raises an error when attempting to use transaction level locks outside a transaction' do
|
|
39
31
|
exception = assert_raises(ArgumentError) do
|
|
40
32
|
Tag.with_advisory_lock 'test', transaction: true do
|
|
@@ -81,3 +73,41 @@ class MySQLTransactionScopingTest < GemTestCase
|
|
|
81
73
|
assert_match(/#{Regexp.escape('require an active transaction')}/, exception.message)
|
|
82
74
|
end
|
|
83
75
|
end
|
|
76
|
+
|
|
77
|
+
if GemTestCase.trilogy_available?
|
|
78
|
+
class TrilogyTransactionScopingTest < GemTestCase
|
|
79
|
+
self.use_transactional_tests = false
|
|
80
|
+
|
|
81
|
+
test 'raises an error when attempting to use transaction level locks' do
|
|
82
|
+
TrilogyTag.transaction do
|
|
83
|
+
exception = assert_raises(ArgumentError) do
|
|
84
|
+
TrilogyTag.with_advisory_lock 'test', transaction: true do
|
|
85
|
+
raise 'Trilogy transaction realm is forbidden!'
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
assert_match(/#{Regexp.escape('not supported')}/, exception.message)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
test 'session locks work within transactions' do
|
|
94
|
+
lock_acquired = false
|
|
95
|
+
TrilogyTag.transaction do
|
|
96
|
+
TrilogyTag.with_advisory_lock 'test' do
|
|
97
|
+
lock_acquired = true
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
assert lock_acquired
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
test 'raises an error when attempting to use transaction level locks outside a transaction' do
|
|
104
|
+
exception = assert_raises(ArgumentError) do
|
|
105
|
+
TrilogyTag.with_advisory_lock 'test', transaction: true do
|
|
106
|
+
raise 'Trilogy gates are closed!'
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
assert_match(/#{Regexp.escape('require an active transaction')}/, exception.message)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
data/with_advisory_lock.gemspec
CHANGED
|
@@ -23,32 +23,9 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.metadata['source_code_uri'] = 'https://github.com/ClosureTree/with_advisory_lock'
|
|
24
24
|
spec.metadata['changelog_uri'] = 'https://github.com/ClosureTree/with_advisory_lock/blob/master/CHANGELOG.md'
|
|
25
25
|
|
|
26
|
-
spec.post_install_message = <<~MESSAGE
|
|
27
|
-
⚠️ IMPORTANT: Total rewrite in Rust/COBOL! ⚠️
|
|
28
|
-
|
|
29
|
-
Now that I got your attention...
|
|
30
|
-
|
|
31
|
-
This version contains a complete internal rewrite. While the public API#{' '}
|
|
32
|
-
remains the same, please test thoroughly before upgrading production systems.
|
|
33
|
-
|
|
34
|
-
New features:
|
|
35
|
-
- Mixed adapters are now fully supported! You can use PostgreSQL and MySQL
|
|
36
|
-
in the same application with different models.
|
|
37
|
-
|
|
38
|
-
Breaking changes:
|
|
39
|
-
- SQLite support has been removed
|
|
40
|
-
- MySQL 5.7 is no longer supported (use MySQL 8+)
|
|
41
|
-
- Rails 7.1 is no longer supported (use Rails 7.2+)
|
|
42
|
-
- Private APIs have been removed (Base, DatabaseAdapterSupport, etc.)
|
|
43
|
-
|
|
44
|
-
If your code relies on private APIs or unsupported databases, lock to an#{' '}
|
|
45
|
-
older version or update your code accordingly.
|
|
46
|
-
MESSAGE
|
|
47
|
-
|
|
48
26
|
spec.add_dependency 'activerecord', '>= 7.2'
|
|
49
|
-
spec.add_dependency 'zeitwerk', '>= 2.7'
|
|
50
27
|
|
|
51
|
-
spec.add_development_dependency 'maxitest'
|
|
28
|
+
spec.add_development_dependency 'maxitest', '6.2.0'
|
|
52
29
|
spec.add_development_dependency 'minitest-reporters'
|
|
53
30
|
spec.add_development_dependency 'mocha'
|
|
54
31
|
spec.add_development_dependency 'yard'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: with_advisory_lock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0
|
|
4
|
+
version: 7.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew McEachen
|
|
@@ -24,34 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '7.2'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: zeitwerk
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.7'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.7'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: maxitest
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
44
30
|
requirements:
|
|
45
|
-
- -
|
|
31
|
+
- - '='
|
|
46
32
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
33
|
+
version: 6.2.0
|
|
48
34
|
type: :development
|
|
49
35
|
prerelease: false
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
52
|
-
- -
|
|
38
|
+
- - '='
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
40
|
+
version: 6.2.0
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
42
|
name: minitest-reporters
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,8 +92,6 @@ files:
|
|
|
106
92
|
- ".github/workflows/release.yml"
|
|
107
93
|
- ".gitignore"
|
|
108
94
|
- ".release-please-manifest.json"
|
|
109
|
-
- ".ruby-version"
|
|
110
|
-
- ".tool-versions"
|
|
111
95
|
- CHANGELOG.md
|
|
112
96
|
- Gemfile
|
|
113
97
|
- LICENSE.txt
|
|
@@ -143,6 +127,10 @@ files:
|
|
|
143
127
|
- test/dummy/app/models/mysql_tag_audit.rb
|
|
144
128
|
- test/dummy/app/models/tag.rb
|
|
145
129
|
- test/dummy/app/models/tag_audit.rb
|
|
130
|
+
- test/dummy/app/models/trilogy_label.rb
|
|
131
|
+
- test/dummy/app/models/trilogy_record.rb
|
|
132
|
+
- test/dummy/app/models/trilogy_tag.rb
|
|
133
|
+
- test/dummy/app/models/trilogy_tag_audit.rb
|
|
146
134
|
- test/dummy/config.ru
|
|
147
135
|
- test/dummy/config/application.rb
|
|
148
136
|
- test/dummy/config/boot.rb
|
|
@@ -151,9 +139,11 @@ files:
|
|
|
151
139
|
- test/dummy/config/routes.rb
|
|
152
140
|
- test/dummy/db/schema.rb
|
|
153
141
|
- test/dummy/db/secondary_schema.rb
|
|
142
|
+
- test/dummy/db/trilogy_schema.rb
|
|
154
143
|
- test/dummy/lib/tasks/db.rake
|
|
155
144
|
- test/sanity_check_test.rb
|
|
156
145
|
- test/test_helper.rb
|
|
146
|
+
- test/with_advisory_lock/blocking_test.rb
|
|
157
147
|
- test/with_advisory_lock/concern_test.rb
|
|
158
148
|
- test/with_advisory_lock/lock_test.rb
|
|
159
149
|
- test/with_advisory_lock/multi_adapter_test.rb
|
|
@@ -173,16 +163,6 @@ metadata:
|
|
|
173
163
|
homepage_uri: https://github.com/ClosureTree/with_advisory_lock
|
|
174
164
|
source_code_uri: https://github.com/ClosureTree/with_advisory_lock
|
|
175
165
|
changelog_uri: https://github.com/ClosureTree/with_advisory_lock/blob/master/CHANGELOG.md
|
|
176
|
-
post_install_message: "⚠️ IMPORTANT: Total rewrite in Rust/COBOL! ⚠️\n\nNow that
|
|
177
|
-
I got your attention...\n\nThis version contains a complete internal rewrite. While
|
|
178
|
-
the public API \nremains the same, please test thoroughly before upgrading production
|
|
179
|
-
systems.\n\nNew features:\n- Mixed adapters are now fully supported! You can use
|
|
180
|
-
PostgreSQL and MySQL\n in the same application with different models.\n\nBreaking
|
|
181
|
-
changes:\n- SQLite support has been removed\n- MySQL 5.7 is no longer supported
|
|
182
|
-
(use MySQL 8+)\n- Rails 7.1 is no longer supported (use Rails 7.2+)\n- Private APIs
|
|
183
|
-
have been removed (Base, DatabaseAdapterSupport, etc.)\n\nIf your code relies on
|
|
184
|
-
private APIs or unsupported databases, lock to an \nolder version or update your
|
|
185
|
-
code accordingly.\n"
|
|
186
166
|
rdoc_options: []
|
|
187
167
|
require_paths:
|
|
188
168
|
- lib
|
|
@@ -197,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
197
177
|
- !ruby/object:Gem::Version
|
|
198
178
|
version: '0'
|
|
199
179
|
requirements: []
|
|
200
|
-
rubygems_version:
|
|
180
|
+
rubygems_version: 4.0.10
|
|
201
181
|
specification_version: 4
|
|
202
182
|
summary: Advisory locking for ActiveRecord
|
|
203
183
|
test_files: []
|
data/.ruby-version
DELETED
data/.tool-versions
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ruby 3.4.6
|