fibered_mysql2 0.3.0 → 0.4.0.pre.tstarck.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/.github/workflows/build.yml +2 -3
- data/.ruby-version +1 -1
- data/Appraisals +7 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +152 -126
- data/fibered_mysql2.gemspec +1 -1
- data/gemfiles/rails_7_0.gemfile +4 -2
- data/gemfiles/{rails_6_1.gemfile → rails_7_1.gemfile} +2 -3
- data/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +10 -14
- data/lib/fibered_mysql2/fibered_database_connection_pool.rb +35 -50
- data/lib/fibered_mysql2/fibered_mysql2_connection_factory.rb +0 -95
- data/lib/fibered_mysql2/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4de2661b6a53134802496ea91ed73ad10623ee8459f1d4ecdb1ebdef6ea4f63
|
4
|
+
data.tar.gz: 8846ea290e1ed8ccab648c55458809b63cb4a1ca737f405f0ece815b441104cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68e08cebe9eec799298274fa1be5e3f83f7b896b5cbdebad3b3b5cb082fabb92388b80310cdb8bd376605374db8460dad4f9fde4746385d9e9d03f53278bf0a2
|
7
|
+
data.tar.gz: 1ea97ac7495a0bc0085aaf4f45e226ad9110f879d893673ae646c48753f90f4c456156bb29ca63c36ddf827fff96a7aab934f80d43c27dbc534fd602db8472be
|
data/.github/workflows/build.yml
CHANGED
@@ -8,11 +8,11 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
ruby: [3.1, 3.2, 3.3]
|
11
|
+
ruby: [3.1, 3.2, 3.3, 3.4]
|
12
12
|
gemfile:
|
13
13
|
- Gemfile
|
14
|
-
- gemfiles/rails_6_1.gemfile
|
15
14
|
- gemfiles/rails_7_0.gemfile
|
15
|
+
- gemfiles/rails_7_1.gemfile
|
16
16
|
env:
|
17
17
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
18
18
|
steps:
|
@@ -20,6 +20,5 @@ jobs:
|
|
20
20
|
- uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
23
|
-
bundler: 2.2.29
|
24
23
|
bundler-cache: true
|
25
24
|
- run: bundle exec rspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.8
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,27 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.4.0] - Unreleased
|
8
|
+
### Added
|
9
|
+
- Support for Rails 7.1
|
10
|
+
|
11
|
+
### Removed
|
12
|
+
- Removed support for Rails 6.1 and below.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
#### FiberedMysql2Adapter
|
16
|
+
- Updated to no longer include EM::Synchrony::ActiveRecord::Adapter_4_2 as it is no longer necessary.
|
17
|
+
- Removed TransactionManager overrides as they are no longer necessary.
|
18
|
+
|
19
|
+
#### FiberedMysql2::FiberedDatabaseConnectionPool
|
20
|
+
- Updated to only override methods needed in Rails 7.0.
|
21
|
+
- Removed double-checking in #connection for cached connection.
|
22
|
+
- Updated #checkout patch to use #reap instead of our custom #reaped_connections method.
|
23
|
+
|
24
|
+
## [0.3.1] - 2024-10-30
|
25
|
+
### Fixed
|
26
|
+
- Fixed bug in FiberedMysqlAdapter.new_client that was causing `uninitialized constant` errors.
|
27
|
+
|
7
28
|
## [0.3.0] - 2024-10-23
|
8
29
|
### Added
|
9
30
|
- Support for Rails 7.0.
|
data/Gemfile
CHANGED
@@ -7,10 +7,9 @@ gemspec
|
|
7
7
|
|
8
8
|
gem 'appraisal'
|
9
9
|
gem 'appraisal-matrix'
|
10
|
-
gem 'coveralls', require: false
|
11
10
|
gem 'mysql2', '~> 0.5'
|
12
11
|
gem 'nokogiri'
|
13
12
|
gem 'pry'
|
14
13
|
gem 'pry-byebug'
|
15
14
|
gem 'rake'
|
16
|
-
gem 'rspec'
|
15
|
+
gem 'rspec', '~> 3.12.0' # Rspec 3.13 is causing segfaults for some reason in CI...
|
data/Gemfile.lock
CHANGED
@@ -1,77 +1,89 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fibered_mysql2 (0.
|
4
|
+
fibered_mysql2 (0.4.0.pre.tstarck.1)
|
5
5
|
em-synchrony (~> 1.0)
|
6
|
-
rails (>=
|
6
|
+
rails (>= 7.0, < 7.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (7.
|
12
|
-
actionpack (= 7.
|
13
|
-
activesupport (= 7.
|
11
|
+
actioncable (7.1.5.1)
|
12
|
+
actionpack (= 7.1.5.1)
|
13
|
+
activesupport (= 7.1.5.1)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
zeitwerk (~> 2.6)
|
17
|
+
actionmailbox (7.1.5.1)
|
18
|
+
actionpack (= 7.1.5.1)
|
19
|
+
activejob (= 7.1.5.1)
|
20
|
+
activerecord (= 7.1.5.1)
|
21
|
+
activestorage (= 7.1.5.1)
|
22
|
+
activesupport (= 7.1.5.1)
|
22
23
|
mail (>= 2.7.1)
|
23
24
|
net-imap
|
24
25
|
net-pop
|
25
26
|
net-smtp
|
26
|
-
actionmailer (7.
|
27
|
-
actionpack (= 7.
|
28
|
-
actionview (= 7.
|
29
|
-
activejob (= 7.
|
30
|
-
activesupport (= 7.
|
27
|
+
actionmailer (7.1.5.1)
|
28
|
+
actionpack (= 7.1.5.1)
|
29
|
+
actionview (= 7.1.5.1)
|
30
|
+
activejob (= 7.1.5.1)
|
31
|
+
activesupport (= 7.1.5.1)
|
31
32
|
mail (~> 2.5, >= 2.5.4)
|
32
33
|
net-imap
|
33
34
|
net-pop
|
34
35
|
net-smtp
|
35
|
-
rails-dom-testing (~> 2.
|
36
|
-
actionpack (7.
|
37
|
-
actionview (= 7.
|
38
|
-
activesupport (= 7.
|
39
|
-
|
36
|
+
rails-dom-testing (~> 2.2)
|
37
|
+
actionpack (7.1.5.1)
|
38
|
+
actionview (= 7.1.5.1)
|
39
|
+
activesupport (= 7.1.5.1)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
racc
|
42
|
+
rack (>= 2.2.4)
|
43
|
+
rack-session (>= 1.0.1)
|
40
44
|
rack-test (>= 0.6.3)
|
41
|
-
rails-dom-testing (~> 2.
|
42
|
-
rails-html-sanitizer (~> 1.
|
43
|
-
actiontext (7.
|
44
|
-
actionpack (= 7.
|
45
|
-
activerecord (= 7.
|
46
|
-
activestorage (= 7.
|
47
|
-
activesupport (= 7.
|
45
|
+
rails-dom-testing (~> 2.2)
|
46
|
+
rails-html-sanitizer (~> 1.6)
|
47
|
+
actiontext (7.1.5.1)
|
48
|
+
actionpack (= 7.1.5.1)
|
49
|
+
activerecord (= 7.1.5.1)
|
50
|
+
activestorage (= 7.1.5.1)
|
51
|
+
activesupport (= 7.1.5.1)
|
48
52
|
globalid (>= 0.6.0)
|
49
53
|
nokogiri (>= 1.8.5)
|
50
|
-
actionview (7.
|
51
|
-
activesupport (= 7.
|
54
|
+
actionview (7.1.5.1)
|
55
|
+
activesupport (= 7.1.5.1)
|
52
56
|
builder (~> 3.1)
|
53
|
-
erubi (~> 1.
|
54
|
-
rails-dom-testing (~> 2.
|
55
|
-
rails-html-sanitizer (~> 1.
|
56
|
-
activejob (7.
|
57
|
-
activesupport (= 7.
|
57
|
+
erubi (~> 1.11)
|
58
|
+
rails-dom-testing (~> 2.2)
|
59
|
+
rails-html-sanitizer (~> 1.6)
|
60
|
+
activejob (7.1.5.1)
|
61
|
+
activesupport (= 7.1.5.1)
|
58
62
|
globalid (>= 0.3.6)
|
59
|
-
activemodel (7.
|
60
|
-
activesupport (= 7.
|
61
|
-
activerecord (7.
|
62
|
-
activemodel (= 7.
|
63
|
-
activesupport (= 7.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
activemodel (7.1.5.1)
|
64
|
+
activesupport (= 7.1.5.1)
|
65
|
+
activerecord (7.1.5.1)
|
66
|
+
activemodel (= 7.1.5.1)
|
67
|
+
activesupport (= 7.1.5.1)
|
68
|
+
timeout (>= 0.4.0)
|
69
|
+
activestorage (7.1.5.1)
|
70
|
+
actionpack (= 7.1.5.1)
|
71
|
+
activejob (= 7.1.5.1)
|
72
|
+
activerecord (= 7.1.5.1)
|
73
|
+
activesupport (= 7.1.5.1)
|
69
74
|
marcel (~> 1.0)
|
70
|
-
|
71
|
-
|
75
|
+
activesupport (7.1.5.1)
|
76
|
+
base64
|
77
|
+
benchmark (>= 0.3)
|
78
|
+
bigdecimal
|
72
79
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
80
|
+
connection_pool (>= 2.2.5)
|
81
|
+
drb
|
73
82
|
i18n (>= 1.6, < 2)
|
83
|
+
logger (>= 1.4.2)
|
74
84
|
minitest (>= 5.1)
|
85
|
+
mutex_m
|
86
|
+
securerandom (>= 0.3)
|
75
87
|
tzinfo (~> 2.0)
|
76
88
|
appraisal (2.5.0)
|
77
89
|
bundler
|
@@ -79,31 +91,36 @@ GEM
|
|
79
91
|
thor (>= 0.14.0)
|
80
92
|
appraisal-matrix (0.3.0)
|
81
93
|
appraisal (~> 2.2)
|
82
|
-
|
94
|
+
base64 (0.3.0)
|
95
|
+
benchmark (0.4.1)
|
96
|
+
bigdecimal (3.2.2)
|
83
97
|
builder (3.3.0)
|
84
|
-
byebug (
|
98
|
+
byebug (12.0.0)
|
99
|
+
cgi (0.5.0)
|
85
100
|
coderay (1.1.3)
|
86
|
-
concurrent-ruby (1.3.
|
87
|
-
|
88
|
-
json (>= 1.8, < 3)
|
89
|
-
simplecov (~> 0.16.1)
|
90
|
-
term-ansicolor (~> 1.3)
|
91
|
-
thor (>= 0.19.4, < 2.0)
|
92
|
-
tins (~> 1.6)
|
101
|
+
concurrent-ruby (1.3.5)
|
102
|
+
connection_pool (2.5.3)
|
93
103
|
crass (1.0.6)
|
94
|
-
date (3.
|
95
|
-
diff-lcs (1.
|
96
|
-
|
104
|
+
date (3.4.1)
|
105
|
+
diff-lcs (1.6.2)
|
106
|
+
drb (2.2.3)
|
97
107
|
em-synchrony (1.0.6)
|
98
108
|
eventmachine (>= 1.0.0.beta.1)
|
99
|
-
|
109
|
+
erb (4.0.4)
|
110
|
+
cgi (>= 0.3.3)
|
111
|
+
erubi (1.13.1)
|
100
112
|
eventmachine (1.2.7)
|
101
113
|
globalid (1.2.1)
|
102
114
|
activesupport (>= 6.1)
|
103
|
-
i18n (1.14.
|
115
|
+
i18n (1.14.7)
|
104
116
|
concurrent-ruby (~> 1.0)
|
105
|
-
|
106
|
-
|
117
|
+
io-console (0.8.1)
|
118
|
+
irb (1.15.2)
|
119
|
+
pp (>= 0.6.0)
|
120
|
+
rdoc (>= 4.0.0)
|
121
|
+
reline (>= 0.4.2)
|
122
|
+
logger (1.7.0)
|
123
|
+
loofah (2.24.1)
|
107
124
|
crass (~> 1.0.2)
|
108
125
|
nokogiri (>= 1.12.0)
|
109
126
|
mail (2.8.1)
|
@@ -114,90 +131,100 @@ GEM
|
|
114
131
|
marcel (1.0.4)
|
115
132
|
method_source (1.1.0)
|
116
133
|
mini_mime (1.1.5)
|
117
|
-
mini_portile2 (2.8.
|
118
|
-
minitest (5.25.
|
134
|
+
mini_portile2 (2.8.9)
|
135
|
+
minitest (5.25.5)
|
136
|
+
mutex_m (0.3.0)
|
119
137
|
mysql2 (0.5.6)
|
120
|
-
net-imap (0.5.
|
138
|
+
net-imap (0.5.9)
|
121
139
|
date
|
122
140
|
net-protocol
|
123
141
|
net-pop (0.1.2)
|
124
142
|
net-protocol
|
125
143
|
net-protocol (0.2.2)
|
126
144
|
timeout
|
127
|
-
net-smtp (0.5.
|
145
|
+
net-smtp (0.5.1)
|
128
146
|
net-protocol
|
129
|
-
nio4r (2.7.
|
130
|
-
nokogiri (1.
|
147
|
+
nio4r (2.7.4)
|
148
|
+
nokogiri (1.18.9)
|
131
149
|
mini_portile2 (~> 2.8.2)
|
132
150
|
racc (~> 1.4)
|
133
|
-
|
151
|
+
pp (0.6.2)
|
152
|
+
prettyprint
|
153
|
+
prettyprint (0.2.0)
|
154
|
+
pry (0.15.2)
|
134
155
|
coderay (~> 1.1)
|
135
156
|
method_source (~> 1.0)
|
136
|
-
pry-byebug (3.
|
137
|
-
byebug (~>
|
138
|
-
pry (>= 0.13, < 0.
|
157
|
+
pry-byebug (3.11.0)
|
158
|
+
byebug (~> 12.0)
|
159
|
+
pry (>= 0.13, < 0.16)
|
160
|
+
psych (5.2.6)
|
161
|
+
date
|
162
|
+
stringio
|
139
163
|
racc (1.8.1)
|
140
|
-
rack (
|
141
|
-
rack-
|
164
|
+
rack (3.2.0)
|
165
|
+
rack-session (2.1.1)
|
166
|
+
base64 (>= 0.1.0)
|
167
|
+
rack (>= 3.0.0)
|
168
|
+
rack-test (2.2.0)
|
142
169
|
rack (>= 1.3)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
170
|
+
rackup (2.2.1)
|
171
|
+
rack (>= 3)
|
172
|
+
rails (7.1.5.1)
|
173
|
+
actioncable (= 7.1.5.1)
|
174
|
+
actionmailbox (= 7.1.5.1)
|
175
|
+
actionmailer (= 7.1.5.1)
|
176
|
+
actionpack (= 7.1.5.1)
|
177
|
+
actiontext (= 7.1.5.1)
|
178
|
+
actionview (= 7.1.5.1)
|
179
|
+
activejob (= 7.1.5.1)
|
180
|
+
activemodel (= 7.1.5.1)
|
181
|
+
activerecord (= 7.1.5.1)
|
182
|
+
activestorage (= 7.1.5.1)
|
183
|
+
activesupport (= 7.1.5.1)
|
155
184
|
bundler (>= 1.15.0)
|
156
|
-
railties (= 7.
|
157
|
-
rails-dom-testing (2.
|
185
|
+
railties (= 7.1.5.1)
|
186
|
+
rails-dom-testing (2.3.0)
|
158
187
|
activesupport (>= 5.0.0)
|
159
188
|
minitest
|
160
189
|
nokogiri (>= 1.6)
|
161
|
-
rails-html-sanitizer (1.6.
|
190
|
+
rails-html-sanitizer (1.6.2)
|
162
191
|
loofah (~> 2.21)
|
163
|
-
nokogiri (
|
164
|
-
railties (7.
|
165
|
-
actionpack (= 7.
|
166
|
-
activesupport (= 7.
|
167
|
-
|
192
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
193
|
+
railties (7.1.5.1)
|
194
|
+
actionpack (= 7.1.5.1)
|
195
|
+
activesupport (= 7.1.5.1)
|
196
|
+
irb
|
197
|
+
rackup (>= 1.0.0)
|
168
198
|
rake (>= 12.2)
|
169
|
-
thor (~> 1.0)
|
170
|
-
zeitwerk (~> 2.
|
171
|
-
rake (13.
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
199
|
+
thor (~> 1.0, >= 1.2.2)
|
200
|
+
zeitwerk (~> 2.6)
|
201
|
+
rake (13.3.0)
|
202
|
+
rdoc (6.14.2)
|
203
|
+
erb
|
204
|
+
psych (>= 4.0.0)
|
205
|
+
reline (0.6.2)
|
206
|
+
io-console (~> 0.5)
|
207
|
+
rspec (3.12.0)
|
208
|
+
rspec-core (~> 3.12.0)
|
209
|
+
rspec-expectations (~> 3.12.0)
|
210
|
+
rspec-mocks (~> 3.12.0)
|
211
|
+
rspec-core (3.12.3)
|
212
|
+
rspec-support (~> 3.12.0)
|
213
|
+
rspec-expectations (3.12.4)
|
179
214
|
diff-lcs (>= 1.2.0, < 2.0)
|
180
|
-
rspec-support (~> 3.
|
181
|
-
rspec-mocks (3.
|
215
|
+
rspec-support (~> 3.12.0)
|
216
|
+
rspec-mocks (3.12.7)
|
182
217
|
diff-lcs (>= 1.2.0, < 2.0)
|
183
|
-
rspec-support (~> 3.
|
184
|
-
rspec-support (3.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
simplecov-html (0.10.2)
|
190
|
-
sync (0.5.0)
|
191
|
-
term-ansicolor (1.11.2)
|
192
|
-
tins (~> 1.0)
|
193
|
-
thor (1.3.2)
|
194
|
-
timeout (0.4.1)
|
195
|
-
tins (1.33.0)
|
196
|
-
bigdecimal
|
197
|
-
sync
|
218
|
+
rspec-support (~> 3.12.0)
|
219
|
+
rspec-support (3.12.2)
|
220
|
+
securerandom (0.4.1)
|
221
|
+
stringio (3.1.7)
|
222
|
+
thor (1.4.0)
|
223
|
+
timeout (0.4.3)
|
198
224
|
tzinfo (2.0.6)
|
199
225
|
concurrent-ruby (~> 1.0)
|
200
|
-
websocket-driver (0.
|
226
|
+
websocket-driver (0.8.0)
|
227
|
+
base64
|
201
228
|
websocket-extensions (>= 0.1.0)
|
202
229
|
websocket-extensions (0.1.5)
|
203
230
|
zeitwerk (2.6.18)
|
@@ -208,14 +235,13 @@ PLATFORMS
|
|
208
235
|
DEPENDENCIES
|
209
236
|
appraisal
|
210
237
|
appraisal-matrix
|
211
|
-
coveralls
|
212
238
|
fibered_mysql2!
|
213
239
|
mysql2 (~> 0.5)
|
214
240
|
nokogiri
|
215
241
|
pry
|
216
242
|
pry-byebug
|
217
243
|
rake
|
218
|
-
rspec
|
244
|
+
rspec (~> 3.12.0)
|
219
245
|
|
220
246
|
BUNDLED WITH
|
221
|
-
2.
|
247
|
+
2.6.9
|
data/fibered_mysql2.gemspec
CHANGED
data/gemfiles/rails_7_0.gemfile
CHANGED
@@ -4,13 +4,15 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "appraisal-matrix"
|
7
|
-
gem "coveralls", require: false
|
8
7
|
gem "mysql2", "~> 0.5"
|
9
8
|
gem "nokogiri"
|
10
9
|
gem "pry"
|
11
10
|
gem "pry-byebug"
|
12
11
|
gem "rake"
|
13
|
-
gem "rspec"
|
12
|
+
gem "rspec", "~> 3.12.0"
|
14
13
|
gem "rails", "~> 7.0.0"
|
14
|
+
gem "mutex_m"
|
15
|
+
gem "base64"
|
16
|
+
gem "bigdecimal"
|
15
17
|
|
16
18
|
gemspec path: "../"
|
@@ -4,13 +4,12 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "appraisal-matrix"
|
7
|
-
gem "coveralls", require: false
|
8
7
|
gem "mysql2", "~> 0.5"
|
9
8
|
gem "nokogiri"
|
10
9
|
gem "pry"
|
11
10
|
gem "pry-byebug"
|
12
11
|
gem "rake"
|
13
|
-
gem "rspec"
|
14
|
-
gem "rails", "~>
|
12
|
+
gem "rspec", "~> 3.12.0"
|
13
|
+
gem "rails", "~> 7.1.0"
|
15
14
|
|
16
15
|
gemspec path: "../"
|
@@ -3,10 +3,12 @@
|
|
3
3
|
require 'em-synchrony'
|
4
4
|
require 'active_model'
|
5
5
|
require 'active_record/errors'
|
6
|
-
|
6
|
+
|
7
|
+
require 'active_record/connection_adapters/mysql2_adapter'
|
8
|
+
require 'em-synchrony/mysql2'
|
7
9
|
|
8
10
|
module FiberedMysql2
|
9
|
-
module
|
11
|
+
module FiberedMysql2Adapter_7_0
|
10
12
|
def lease
|
11
13
|
if in_use?
|
12
14
|
msg = "Cannot lease connection, ".dup
|
@@ -61,28 +63,22 @@ module FiberedMysql2
|
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::
|
65
|
-
|
66
|
+
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
67
|
+
if ::ActiveRecord.gem_version < "7.1"
|
68
|
+
include FiberedMysql2Adapter_7_0
|
69
|
+
end
|
66
70
|
|
67
71
|
class << self
|
68
72
|
# Copied from Mysql2Adapter, except with the EM Mysql2 client
|
69
73
|
def new_client(config)
|
70
74
|
Mysql2::EM::Client.new(config)
|
71
75
|
rescue Mysql2::Error => error
|
72
|
-
if error.error_number ==
|
73
|
-
raise ActiveRecord::NoDatabaseError.
|
74
|
-
elsif error.error_number == ConnectionAdapters::Mysql2Adapter::ER_ACCESS_DENIED_ERROR
|
75
|
-
raise ActiveRecord::DatabaseConnectionError.username_error(config[:username])
|
76
|
-
elsif [ConnectionAdapters::Mysql2Adapter::ER_CONN_HOST_ERROR, ConnectionAdapters::Mysql2Adapter::ER_UNKNOWN_HOST_ERROR].include?(error.error_number)
|
77
|
-
raise ActiveRecord::DatabaseConnectionError.hostname_error(config[:host])
|
76
|
+
if error.error_number == 1049
|
77
|
+
raise ActiveRecord::NoDatabaseError.new, error.message
|
78
78
|
else
|
79
79
|
raise ActiveRecord::ConnectionNotEstablished, error.message
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
84
|
-
def initialize(*args)
|
85
|
-
super
|
86
|
-
end
|
87
83
|
end
|
88
84
|
end
|
@@ -184,33 +184,36 @@ module FiberedMysql2
|
|
184
184
|
end
|
185
185
|
|
186
186
|
module FiberedDatabaseConnectionPool
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
187
|
+
module Adapter_7_0
|
188
|
+
def release_connection(owner_thread = Fiber.current)
|
189
|
+
if (conn = @thread_cached_conns.delete(connection_cache_key(owner_thread)))
|
190
|
+
checkin(conn)
|
191
|
+
end
|
192
192
|
end
|
193
193
|
|
194
|
-
def
|
195
|
-
|
194
|
+
def with_connection
|
195
|
+
unless (conn = cached_connections[current_connection_id]) # Invoca Patch to use Fiber
|
196
|
+
conn = connection
|
197
|
+
fresh_connection = true
|
198
|
+
end
|
199
|
+
yield conn
|
200
|
+
ensure
|
201
|
+
release_connection if fresh_connection
|
196
202
|
end
|
197
203
|
|
198
|
-
def
|
199
|
-
|
200
|
-
reap_connections
|
201
|
-
rescue => ex
|
202
|
-
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
203
|
-
end
|
204
|
-
super
|
204
|
+
def current_thread
|
205
|
+
Fiber.current
|
205
206
|
end
|
206
207
|
|
207
|
-
def
|
208
|
-
|
209
|
-
checkin(conn)
|
210
|
-
end
|
208
|
+
def connection
|
209
|
+
cached_connections[current_connection_id] ||= checkout
|
211
210
|
end
|
212
211
|
end
|
213
|
-
|
212
|
+
|
213
|
+
if ::ActiveRecord.gem_version < "7.1"
|
214
|
+
include Adapter_7_0
|
215
|
+
end
|
216
|
+
include FiberedMonitorMixin # This is switches the connection pool's mutex and condition variables to event machine / Fiber compatible ones.
|
214
217
|
|
215
218
|
def initialize(pool_config)
|
216
219
|
if pool_config.db_config.reaping_frequency
|
@@ -222,41 +225,23 @@ module FiberedMysql2
|
|
222
225
|
@reaper = nil # no need to keep a reference to this since it does nothing in this sub-class
|
223
226
|
end
|
224
227
|
|
225
|
-
def
|
226
|
-
|
227
|
-
# (ThreadSafe::Cache's lookups have volatile semantics)
|
228
|
-
if (result = cached_connections[current_connection_id])
|
229
|
-
result
|
230
|
-
else
|
231
|
-
synchronize do
|
232
|
-
if (result = cached_connections[current_connection_id])
|
233
|
-
result
|
234
|
-
else
|
235
|
-
cached_connections[current_connection_id] = checkout
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def reap_connections
|
242
|
-
cached_connections.values.each do |connection|
|
243
|
-
unless connection.owner.alive?
|
244
|
-
checkin(connection)
|
245
|
-
end
|
246
|
-
end
|
228
|
+
def current_connection_id
|
229
|
+
connection_cache_key(current_thread)
|
247
230
|
end
|
248
231
|
|
249
|
-
|
250
|
-
|
251
|
-
#--
|
252
|
-
# This hook-in method allows for easier monkey-patching fixes needed by
|
253
|
-
# JRuby users that use Fibers.
|
254
|
-
def connection_cache_key(fiber)
|
255
|
-
fiber
|
232
|
+
def cached_connections
|
233
|
+
@thread_cached_conns
|
256
234
|
end
|
257
235
|
|
258
|
-
|
259
|
-
|
236
|
+
# Invoca patch that reaps orphaned connections on checkout. This lets us immediately use a connection left open by dead fibers
|
237
|
+
# instead of waiting for all connections to be used in the pool before they are reaped.
|
238
|
+
def checkout(checkout_timeout = @checkout_timeout)
|
239
|
+
begin
|
240
|
+
reap
|
241
|
+
rescue => ex
|
242
|
+
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
243
|
+
end
|
244
|
+
super
|
260
245
|
end
|
261
246
|
end
|
262
247
|
end
|
@@ -2,101 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative '../active_record/connection_adapters/fibered_mysql2_adapter'
|
4
4
|
|
5
|
-
module EM::Synchrony
|
6
|
-
module ActiveRecord
|
7
|
-
_ = Adapter_4_2
|
8
|
-
module Adapter_4_2
|
9
|
-
def configure_connection
|
10
|
-
super # undo EM::Synchrony's override here
|
11
|
-
end
|
12
|
-
|
13
|
-
def transaction(*args)
|
14
|
-
super # and here
|
15
|
-
end
|
16
|
-
|
17
|
-
_ = TransactionManager
|
18
|
-
class TransactionManager < _
|
19
|
-
# Overriding the em-synchrony override to bring it up to rails 6 requirements.
|
20
|
-
# Changes from the original Rails 6 source are:
|
21
|
-
# 1. the usage of _current_stack created by em-synchrony instead of the Rails provided @stack instance variable
|
22
|
-
# 2. the usage of Fiber.current.object_id as a part of the savepoint transaction name
|
23
|
-
#
|
24
|
-
# Original EM Synchrony Source:
|
25
|
-
# https://github.com/igrigorik/em-synchrony/blob/master/lib/em-synchrony/activerecord_4_2.rb#L35-L44
|
26
|
-
#
|
27
|
-
# Original Rails Source:
|
28
|
-
# https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb#L205-L224
|
29
|
-
def begin_transaction(isolation: nil, joinable: true, _lazy: true)
|
30
|
-
@connection.lock.synchronize do
|
31
|
-
run_commit_callbacks = !current_transaction.joinable?
|
32
|
-
transaction =
|
33
|
-
if _current_stack.empty?
|
34
|
-
::ActiveRecord::ConnectionAdapters::RealTransaction.new(@connection, isolation:, joinable:, run_commit_callbacks: run_commit_callbacks)
|
35
|
-
else
|
36
|
-
::ActiveRecord::ConnectionAdapters::SavepointTransaction.new(@connection, "active_record_#{Fiber.current.object_id}_#{open_transactions}", _current_stack.last, isolation:, joinable:, run_commit_callbacks: run_commit_callbacks)
|
37
|
-
end
|
38
|
-
|
39
|
-
if @connection.supports_lazy_transactions? && lazy_transactions_enabled? && _lazy
|
40
|
-
@has_unmaterialized_transactions = true
|
41
|
-
else
|
42
|
-
transaction.materialize!
|
43
|
-
end
|
44
|
-
_current_stack.push(transaction)
|
45
|
-
transaction
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Overriding the ActiveRecord::TransactionManager#materialize_transactions method to use
|
50
|
-
# fiber safe the _current_stack instead of the @stack instance variable. when marterializing
|
51
|
-
# transactions.
|
52
|
-
def materialize_transactions
|
53
|
-
return if @materializing_transactions
|
54
|
-
return unless @has_unmaterialized_transactions
|
55
|
-
|
56
|
-
@connection.lock.synchronize do
|
57
|
-
begin
|
58
|
-
@materializing_transactions = true
|
59
|
-
_current_stack.each { |t| t.materialize! unless t.materialized? }
|
60
|
-
ensure
|
61
|
-
@materializing_transactions = false
|
62
|
-
end
|
63
|
-
@has_unmaterialized_transactions = false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Overriding the ActiveRecord::TransactionManager#commit_transaction method to use
|
68
|
-
# fiber safe the _current_stack instead of the @stack instance variable. when marterializing
|
69
|
-
# transactions.
|
70
|
-
def commit_transaction
|
71
|
-
@connection.lock.synchronize do
|
72
|
-
transaction = _current_stack.last
|
73
|
-
|
74
|
-
begin
|
75
|
-
transaction.before_commit_records
|
76
|
-
ensure
|
77
|
-
_current_stack.pop
|
78
|
-
end
|
79
|
-
|
80
|
-
transaction.commit
|
81
|
-
transaction.commit_records
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Overriding the ActiveRecord::TransactionManager#rollback_transaction method to use
|
86
|
-
# fiber safe the _current_stack instead of the @stack instance variable. when marterializing
|
87
|
-
# transactions.
|
88
|
-
def rollback_transaction(transaction = nil)
|
89
|
-
@connection.lock.synchronize do
|
90
|
-
transaction ||= _current_stack.pop
|
91
|
-
transaction.rollback
|
92
|
-
transaction.rollback_records
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
5
|
module FiberedMysql2
|
101
6
|
module FiberedMysql2ConnectionFactory
|
102
7
|
def fibered_mysql2_connection(raw_config)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fibered_mysql2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.pre.tstarck.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-synchrony
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '7.0'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '7.
|
36
|
+
version: '7.2'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '7.0'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '7.
|
46
|
+
version: '7.2'
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- development@invoca.com
|
@@ -66,8 +66,8 @@ files:
|
|
66
66
|
- bin/setup
|
67
67
|
- fibered_mysql2.gemspec
|
68
68
|
- gemfiles/.bundle/config
|
69
|
-
- gemfiles/rails_6_1.gemfile
|
70
69
|
- gemfiles/rails_7_0.gemfile
|
70
|
+
- gemfiles/rails_7_1.gemfile
|
71
71
|
- lib/active_record/connection_adapters/fibered_mysql2_adapter.rb
|
72
72
|
- lib/fibered_mysql2.rb
|
73
73
|
- lib/fibered_mysql2/fibered_database_connection_pool.rb
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
98
|
+
rubygems_version: 3.5.22
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: An adapter for fibered mysql2
|