Skip to content

Commit abdff34

Browse files
authored
breaking change: drop support for mysql (#26)
we're not using mysql anymore and maintaining support for it isn't something we're interested in doing anymore. /no-platform
1 parent 3456839 commit abdff34

File tree

18 files changed

+364
-447
lines changed

18 files changed

+364
-447
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
ruby: ['3.2', '3.3', '3.4']
15+
ruby: ["3.2", "3.3", "3.4"]
1616
gemfile:
1717
- gemfiles/rails_7_0.gemfile
1818
- gemfiles/rails_7_1.gemfile
@@ -35,25 +35,15 @@ jobs:
3535
ports:
3636
# Maps tcp port 5432 on service container to the host
3737
- 5432:5432
38-
mysql:
39-
image: mysql:5.7
40-
env:
41-
MYSQL_ALLOW_EMPTY_PASSWORD: yes
42-
MYSQL_DATABASE: with_transactional_lock_test
43-
DB_ADAPTER: mysql
44-
ports:
45-
- 3306:3306
46-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
47-
4838
steps:
49-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
50-
- uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1
51-
env:
52-
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
53-
with:
54-
ruby-version: ${{ matrix.ruby }}
55-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56-
- name: Run tests
57-
env:
58-
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
59-
run: bundle exec rake
39+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
40+
- uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1
41+
env:
42+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
43+
with:
44+
ruby-version: ${{ matrix.ruby }}
45+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
46+
- name: Run tests
47+
env:
48+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
49+
run: bundle exec rake

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
## [3.0.0]
9+
10+
### Removed
11+
12+
- Removed support for mysql

Gemfile.lock

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
with_transactional_lock (2.4.0)
4+
with_transactional_lock (3.0.0)
55
activerecord (>= 7.0, < 8.1)
66
railties (>= 7.0, < 8.1)
77

@@ -86,7 +86,6 @@ GEM
8686
crass (~> 1.0.2)
8787
nokogiri (>= 1.12.0)
8888
minitest (5.25.4)
89-
mysql2 (0.5.6)
9089
nokogiri (1.18.2-arm64-darwin)
9190
racc (~> 1.4)
9291
nokogiri (1.18.2-x86_64-darwin)
@@ -213,7 +212,6 @@ DEPENDENCIES
213212
appraisal
214213
betterlint
215214
database_cleaner
216-
mysql2
217215
pg
218216
rspec-rails
219217
rspec-retry

README.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# with_transactional_lock
22

33
A simple extension to ActiveRecord for performing advisory locking on
4-
MySQL and PostgreSQL.
4+
PostgreSQL.
55

66
An advisory lock is a database-level mutex that can be used to prevent
77
concurrent access to a shared resource or to prevent two workers from
88
performing the same process concurrently.
99

1010
This gem is different from other advisory locking gems because it
11-
uses advisory transaction locks instead of advisory session locks.
11+
uses advisory transaction locks instead of advisory session locks.
1212

1313
## Why transactional?
1414

@@ -31,7 +31,7 @@ preventing leaks.
3131
Additionally, application developers tend to think about discrete units
3232
of database work in terms of transactions. By leveraging the transaction
3333
boundary, we ensure the advisory lock is released at the earliest
34-
possible moment that it can be and no sooner.
34+
possible moment that it can be and no sooner.
3535

3636
## Lock acquisition efficiency & fairness
3737

@@ -60,25 +60,16 @@ waiting on I/O (possibly allowing another thread to use the CPU).
6060

6161
Add this line to your application's Gemfile:
6262

63-
``` ruby
63+
```ruby
6464
gem 'with_transactional_lock'
6565
```
6666

6767
And then bundle install:
6868

6969
```
70-
$ bundle install
71-
```
72-
73-
And then if you're using MySQL, you will need to run the installer:
74-
75-
```
76-
$ rails g with_transactional_lock:install
70+
bundle install
7771
```
7872

79-
This will create a migration that will add an
80-
`transactional_advisory_locks` table to your database.
81-
8273
## Usage
8374

8475
Because transactional locks are meaningless outside of the context of a
@@ -92,12 +83,12 @@ ActiveRecord::Base.with_transactional_lock('name_of_a_resource') do
9283
end
9384
```
9485

95-
This call will attempt to acquire an exclusive lock using the provided
86+
This call will attempt to acquire an exclusive lock using the provided
9687
lock name. It will wait indefinitely for that lock -- or at least as
9788
long as your database connection timeout is willing to allow. Once the
9889
lock is acquired you will have exclusive ownership of the advisory lock
9990
with the name that you provided. Your block is free to execute its
100-
critical work. Upon completion of your transaction, the lock will be
91+
critical work. Upon completion of your transaction, the lock will be
10192
released.
10293

10394
## Supported databases
@@ -109,15 +100,6 @@ PostgreSQL has first-class support for transactional advisory locks via
109100
duration of a given transaction and automatically released upon
110101
transaction commit.
111102

112-
### MySQL
113-
114-
MySQL does not have built-in support for transactional advisory locks.
115-
So, MySQL gets a special treatment. We emulate the behavior of PostgreSQL
116-
using a special `transactional_advisory_locks` table with a unique index
117-
on the `lock_id` column. This allows us to provide the same transactional
118-
and mutual exclusivity guarantees as PostgreSQL. The trade-off is that
119-
you need to add another table to your database.
120-
121103
## License
122104

123105
Any contributions made to this project are covered under the MIT License, found [here](LICENSE)

gemfiles/rails_7_0.gemfile.lock

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
with_transactional_lock (2.4.0)
4+
with_transactional_lock (3.0.0)
55
activerecord (>= 7.0, < 8.1)
66
railties (>= 7.0, < 8.1)
77

@@ -35,57 +35,58 @@ GEM
3535
bundler
3636
rake
3737
thor (>= 0.14.0)
38-
ast (2.4.2)
39-
base64 (0.2.0)
40-
benchmark (0.4.0)
41-
betterlint (1.16.0)
42-
rubocop (~> 1.62.0)
43-
rubocop-graphql (~> 1.5.0)
44-
rubocop-performance (~> 1.21.0)
45-
rubocop-rails (~> 2.24.0)
46-
rubocop-rake (~> 0.6.0)
47-
rubocop-rspec (~> 2.28.0)
48-
bigdecimal (3.1.9)
38+
ast (2.4.3)
39+
base64 (0.3.0)
40+
benchmark (0.4.1)
41+
betterlint (1.23.0)
42+
rubocop (~> 1.71)
43+
rubocop-graphql (~> 1.5)
44+
rubocop-performance (~> 1.23)
45+
rubocop-rails (~> 2.29)
46+
rubocop-rake (~> 0.6)
47+
rubocop-rspec (~> 2.29)
48+
bigdecimal (3.2.2)
4949
builder (3.3.0)
5050
concurrent-ruby (1.3.4)
5151
crass (1.0.6)
5252
database_cleaner (2.1.0)
5353
database_cleaner-active_record (>= 2, < 3)
54-
database_cleaner-active_record (2.2.0)
54+
database_cleaner-active_record (2.2.1)
5555
activerecord (>= 5.a)
5656
database_cleaner-core (~> 2.0.0)
5757
database_cleaner-core (2.0.1)
58-
diff-lcs (1.5.1)
59-
drb (2.2.1)
58+
diff-lcs (1.6.2)
59+
drb (2.2.3)
6060
erubi (1.13.1)
6161
i18n (1.14.7)
6262
concurrent-ruby (~> 1.0)
63-
json (2.9.1)
64-
language_server-protocol (3.17.0.3)
65-
logger (1.6.5)
66-
loofah (2.24.0)
63+
json (2.13.0)
64+
language_server-protocol (3.17.0.5)
65+
lint_roller (1.1.0)
66+
logger (1.7.0)
67+
loofah (2.24.1)
6768
crass (~> 1.0.2)
6869
nokogiri (>= 1.12.0)
6970
method_source (1.1.0)
70-
minitest (5.25.4)
71+
minitest (5.25.5)
7172
mutex_m (0.3.0)
72-
mysql2 (0.5.6)
73-
nokogiri (1.18.2-arm64-darwin)
73+
nokogiri (1.18.8-arm64-darwin)
7474
racc (~> 1.4)
75-
nokogiri (1.18.2-x86_64-darwin)
75+
nokogiri (1.18.8-x86_64-darwin)
7676
racc (~> 1.4)
77-
nokogiri (1.18.2-x86_64-linux-gnu)
77+
nokogiri (1.18.8-x86_64-linux-gnu)
7878
racc (~> 1.4)
79-
parallel (1.26.3)
80-
parser (3.3.7.0)
79+
parallel (1.27.0)
80+
parser (3.3.8.0)
8181
ast (~> 2.4.1)
8282
racc
8383
pg (1.5.9)
84+
prism (1.4.0)
8485
racc (1.8.1)
85-
rack (2.2.10)
86+
rack (2.2.17)
8687
rack-test (2.2.0)
8788
rack (>= 1.3)
88-
rails-dom-testing (2.2.0)
89+
rails-dom-testing (2.3.0)
8990
activesupport (>= 5.0.0)
9091
minitest
9192
nokogiri (>= 1.6)
@@ -100,18 +101,17 @@ GEM
100101
thor (~> 1.0)
101102
zeitwerk (~> 2.5)
102103
rainbow (3.1.1)
103-
rake (13.2.1)
104+
rake (13.3.0)
104105
regexp_parser (2.10.0)
105-
rexml (3.4.0)
106-
rspec-core (3.13.2)
106+
rspec-core (3.13.5)
107107
rspec-support (~> 3.13.0)
108-
rspec-expectations (3.13.3)
108+
rspec-expectations (3.13.5)
109109
diff-lcs (>= 1.2.0, < 2.0)
110110
rspec-support (~> 3.13.0)
111-
rspec-mocks (3.13.2)
111+
rspec-mocks (3.13.5)
112112
diff-lcs (>= 1.2.0, < 2.0)
113113
rspec-support (~> 3.13.0)
114-
rspec-rails (7.1.0)
114+
rspec-rails (7.1.1)
115115
actionpack (>= 7.0)
116116
activesupport (>= 7.0)
117117
railties (>= 7.0)
@@ -121,37 +121,44 @@ GEM
121121
rspec-support (~> 3.13)
122122
rspec-retry (0.6.2)
123123
rspec-core (> 3.3)
124-
rspec-support (3.13.2)
125-
rubocop (1.62.1)
124+
rspec-support (3.13.4)
125+
rubocop (1.78.0)
126126
json (~> 2.3)
127-
language_server-protocol (>= 3.17.0)
127+
language_server-protocol (~> 3.17.0.2)
128+
lint_roller (~> 1.1.0)
128129
parallel (~> 1.10)
129130
parser (>= 3.3.0.2)
130131
rainbow (>= 2.2.2, < 4.0)
131-
regexp_parser (>= 1.8, < 3.0)
132-
rexml (>= 3.2.5, < 4.0)
133-
rubocop-ast (>= 1.31.1, < 2.0)
132+
regexp_parser (>= 2.9.3, < 3.0)
133+
rubocop-ast (>= 1.45.1, < 2.0)
134134
ruby-progressbar (~> 1.7)
135-
unicode-display_width (>= 2.4.0, < 3.0)
136-
rubocop-ast (1.37.0)
137-
parser (>= 3.3.1.0)
138-
rubocop-capybara (2.21.0)
139-
rubocop (~> 1.41)
140-
rubocop-factory_bot (2.26.1)
141-
rubocop (~> 1.61)
142-
rubocop-graphql (1.5.4)
143-
rubocop (>= 1.50, < 2)
144-
rubocop-performance (1.21.1)
145-
rubocop (>= 1.48.1, < 2.0)
146-
rubocop-ast (>= 1.31.1, < 2.0)
147-
rubocop-rails (2.24.1)
135+
unicode-display_width (>= 2.4.0, < 4.0)
136+
rubocop-ast (1.46.0)
137+
parser (>= 3.3.7.2)
138+
prism (~> 1.4)
139+
rubocop-capybara (2.22.1)
140+
lint_roller (~> 1.1)
141+
rubocop (~> 1.72, >= 1.72.1)
142+
rubocop-factory_bot (2.27.1)
143+
lint_roller (~> 1.1)
144+
rubocop (~> 1.72, >= 1.72.1)
145+
rubocop-graphql (1.5.6)
146+
lint_roller (~> 1.1)
147+
rubocop (>= 1.72.1, < 2)
148+
rubocop-performance (1.25.0)
149+
lint_roller (~> 1.1)
150+
rubocop (>= 1.75.0, < 2.0)
151+
rubocop-ast (>= 1.38.0, < 2.0)
152+
rubocop-rails (2.32.0)
148153
activesupport (>= 4.2.0)
154+
lint_roller (~> 1.1)
149155
rack (>= 1.1)
150-
rubocop (>= 1.33.0, < 2.0)
151-
rubocop-ast (>= 1.31.1, < 2.0)
152-
rubocop-rake (0.6.0)
153-
rubocop (~> 1.0)
154-
rubocop-rspec (2.28.0)
156+
rubocop (>= 1.75.0, < 2.0)
157+
rubocop-ast (>= 1.44.0, < 2.0)
158+
rubocop-rake (0.7.1)
159+
lint_roller (~> 1.1)
160+
rubocop (>= 1.72.1)
161+
rubocop-rspec (2.31.0)
155162
rubocop (~> 1.40)
156163
rubocop-capybara (~> 2.17)
157164
rubocop-factory_bot (~> 2.22)
@@ -162,8 +169,10 @@ GEM
162169
thor (1.3.2)
163170
tzinfo (2.0.6)
164171
concurrent-ruby (~> 1.0)
165-
unicode-display_width (2.6.0)
166-
zeitwerk (2.7.1)
172+
unicode-display_width (3.1.4)
173+
unicode-emoji (~> 4.0, >= 4.0.4)
174+
unicode-emoji (4.0.4)
175+
zeitwerk (2.7.3)
167176

168177
PLATFORMS
169178
arm64-darwin-22
@@ -182,7 +191,6 @@ DEPENDENCIES
182191
drb
183192
logger
184193
mutex_m
185-
mysql2
186194
pg
187195
railties (~> 7.0.0)
188196
rspec-rails

0 commit comments

Comments
 (0)