with_advisory_lock 4.6.0 → 5.3.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-mysql5.yml +61 -0
- data/.github/workflows/ci-mysql8.yml +62 -0
- data/.github/workflows/ci-postgresql.yml +64 -0
- data/.github/workflows/ci-sqlite3.yml +54 -0
- data/.github/workflows/release.yml +17 -0
- data/.gitignore +2 -0
- data/.release-please-manifest.json +1 -0
- data/.ruby-version +2 -0
- data/.tool-versions +1 -1
- data/Appraisals +34 -18
- data/CHANGELOG.md +50 -0
- data/Gemfile +0 -12
- data/LICENSE.txt +4 -4
- data/Makefile +14 -0
- data/README.md +17 -6
- data/docker-compose.yml +20 -0
- data/gemfiles/{activerecord_6.0.gemfile → activerecord_6.1.gemfile} +4 -2
- data/gemfiles/{activerecord_5.2.gemfile → activerecord_7.0.gemfile} +4 -2
- data/gemfiles/activerecord_7.1.gemfile +14 -0
- data/lib/with_advisory_lock/base.rb +18 -4
- data/lib/with_advisory_lock/concern.rb +17 -17
- data/lib/with_advisory_lock/database_adapter_support.rb +7 -47
- data/lib/with_advisory_lock/failed_to_acquire_lock.rb +9 -0
- data/lib/with_advisory_lock/flock.rb +4 -3
- data/lib/with_advisory_lock/mysql.rb +12 -7
- data/lib/with_advisory_lock/postgresql.rb +43 -18
- data/lib/with_advisory_lock/version.rb +3 -1
- data/lib/with_advisory_lock.rb +9 -10
- data/release-please-config.json +9 -0
- data/test/test_helper.rb +66 -0
- data/test/test_models.rb +16 -10
- data/test/with_advisory_lock/base_test.rb +9 -0
- data/test/with_advisory_lock/concern_test.rb +33 -0
- data/test/with_advisory_lock/lock_test.rb +111 -0
- data/test/with_advisory_lock/nesting_test.rb +28 -0
- data/test/with_advisory_lock/options_test.rb +66 -0
- data/test/with_advisory_lock/parallelism_test.rb +75 -0
- data/test/with_advisory_lock/shared_test.rb +134 -0
- data/test/with_advisory_lock/thread_test.rb +61 -0
- data/test/with_advisory_lock/transaction_test.rb +68 -0
- data/with_advisory_lock.gemspec +29 -23
- metadata +56 -47
- data/.travis.yml +0 -38
- data/gemfiles/activerecord_4.2.gemfile +0 -19
- data/gemfiles/activerecord_5.0.gemfile +0 -19
- data/gemfiles/activerecord_5.1.gemfile +0 -19
- data/lib/with_advisory_lock/mysql_no_nesting.rb +0 -20
- data/lib/with_advisory_lock/nested_advisory_lock_error.rb +0 -14
- data/test/concern_test.rb +0 -20
- data/test/database.yml +0 -17
- data/test/lock_test.rb +0 -47
- data/test/minitest_helper.rb +0 -40
- data/test/nesting_test.rb +0 -93
- data/test/options_test.rb +0 -64
- data/test/parallelism_test.rb +0 -77
- data/test/shared_test.rb +0 -131
- data/test/thread_test.rb +0 -60
- data/test/transaction_test.rb +0 -70
- data/tests.sh +0 -11
data/test/transaction_test.rb
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'minitest_helper'
|
|
2
|
-
|
|
3
|
-
describe 'transaction scoping' do
|
|
4
|
-
def supported?
|
|
5
|
-
env_db == :postgresql
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe 'not supported' do
|
|
9
|
-
before do
|
|
10
|
-
skip if supported?
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'raises an error when attempting to use transaction level locks' do
|
|
14
|
-
Tag.transaction do
|
|
15
|
-
exception = proc {
|
|
16
|
-
Tag.with_advisory_lock 'test', transaction: true do
|
|
17
|
-
raise 'should not get here'
|
|
18
|
-
end
|
|
19
|
-
}.must_raise ArgumentError
|
|
20
|
-
exception.message.must_include 'not supported'
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe 'supported' do
|
|
26
|
-
before do
|
|
27
|
-
skip unless env_db == :postgresql
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def pg_lock_count
|
|
31
|
-
ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM pg_locks WHERE locktype = 'advisory';").to_i
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
specify 'session locks release after the block executes' do
|
|
35
|
-
Tag.transaction do
|
|
36
|
-
pg_lock_count.must_equal 0
|
|
37
|
-
Tag.with_advisory_lock 'test' do
|
|
38
|
-
pg_lock_count.must_equal 1
|
|
39
|
-
end
|
|
40
|
-
pg_lock_count.must_equal 0
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
specify 'session locks release when transaction fails inside block' do
|
|
45
|
-
Tag.transaction do
|
|
46
|
-
pg_lock_count.must_equal 0
|
|
47
|
-
|
|
48
|
-
exception = proc {
|
|
49
|
-
Tag.with_advisory_lock 'test' do
|
|
50
|
-
Tag.connection.execute 'SELECT 1/0;'
|
|
51
|
-
end
|
|
52
|
-
}.must_raise ActiveRecord::StatementInvalid
|
|
53
|
-
exception.message.must_include 'division by zero'
|
|
54
|
-
|
|
55
|
-
pg_lock_count.must_equal 0
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
specify 'transaction level locks hold until the transaction completes' do
|
|
60
|
-
Tag.transaction do
|
|
61
|
-
pg_lock_count.must_equal 0
|
|
62
|
-
Tag.with_advisory_lock 'test', transaction: true do
|
|
63
|
-
pg_lock_count.must_equal 1
|
|
64
|
-
end
|
|
65
|
-
pg_lock_count.must_equal 1
|
|
66
|
-
end
|
|
67
|
-
pg_lock_count.must_equal 0
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|