fibered_mysql2 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/Appraisals +1 -1
- data/CHANGELOG.md +16 -1
- data/Gemfile.lock +71 -72
- data/fibered_mysql2.gemspec +1 -1
- data/gemfiles/{rails_6_0.gemfile → rails_7_0.gemfile} +1 -1
- data/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +14 -15
- data/lib/fibered_mysql2/fibered_database_connection_pool.rb +5 -35
- data/lib/fibered_mysql2/fibered_mysql2_connection_factory.rb +73 -89
- data/lib/fibered_mysql2/hash_config_override.rb +2 -0
- data/lib/fibered_mysql2/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf06a5be94da99bc7d1e0de4b5268ff04a72fd7671e6c4d522186d1ea67dd0b
|
4
|
+
data.tar.gz: 931890052763e7fcf2f1ffb7925848004dc54c4c583f89d24c258cbe1537a67a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42cab06e4e9bccd07df1436db08c8fb0e8038027690bc03cc58a34eab99ecfd6cccedbdde27f63f9607ce391bea3de8d941cc720775deb7c0c7d65134f405bae
|
7
|
+
data.tar.gz: be4a1bd1357e9d51e2e76e48f93ede62f8b7c3cb9cf515a042cf9d10f4d2afe63721349f5afe65a67d2cc9246741aab39a80c7aa903bafde77d95d75c026cd05
|
data/.github/workflows/build.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,24 @@ 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.3.1] - 2024-10-30
|
8
|
+
### Fixed
|
9
|
+
- Fixed bug in FiberedMysqlAdapter.new_client that was causing `uninitialized constant` errors.
|
10
|
+
|
11
|
+
## [0.3.0] - 2024-10-23
|
12
|
+
### Added
|
13
|
+
- Support for Rails 7.0.
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
- Removed support for Rails 6.0 and Rails 5.
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- Clean up FiberedMysql2ConnectionFactory#fibered_mysql2_connection to better match Mysql2Adapter behavior.
|
20
|
+
- Change FiberedMysql2::FiberedDatabaseConnectionPool#initialize to match ActiveRecord::ConnectionAdapters::ConnectionPool#initialize arguments.
|
21
|
+
|
7
22
|
## [0.2.1] - 2024-08-19
|
8
23
|
### Fixed
|
9
|
-
- Fixed bugs in Rails 6.1
|
24
|
+
- Fixed bugs in Rails 6.1
|
10
25
|
|
11
26
|
## [0.2.0] - 2023-01-12
|
12
27
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -1,72 +1,78 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fibered_mysql2 (0.
|
4
|
+
fibered_mysql2 (0.3.1)
|
5
5
|
em-synchrony (~> 1.0)
|
6
|
-
rails (>=
|
6
|
+
rails (>= 6.1, < 7.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (
|
12
|
-
actionpack (=
|
13
|
-
activesupport (=
|
11
|
+
actioncable (7.0.8.6)
|
12
|
+
actionpack (= 7.0.8.6)
|
13
|
+
activesupport (= 7.0.8.6)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (
|
17
|
-
actionpack (=
|
18
|
-
activejob (=
|
19
|
-
activerecord (=
|
20
|
-
activestorage (=
|
21
|
-
activesupport (=
|
16
|
+
actionmailbox (7.0.8.6)
|
17
|
+
actionpack (= 7.0.8.6)
|
18
|
+
activejob (= 7.0.8.6)
|
19
|
+
activerecord (= 7.0.8.6)
|
20
|
+
activestorage (= 7.0.8.6)
|
21
|
+
activesupport (= 7.0.8.6)
|
22
22
|
mail (>= 2.7.1)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
net-imap
|
24
|
+
net-pop
|
25
|
+
net-smtp
|
26
|
+
actionmailer (7.0.8.6)
|
27
|
+
actionpack (= 7.0.8.6)
|
28
|
+
actionview (= 7.0.8.6)
|
29
|
+
activejob (= 7.0.8.6)
|
30
|
+
activesupport (= 7.0.8.6)
|
28
31
|
mail (~> 2.5, >= 2.5.4)
|
32
|
+
net-imap
|
33
|
+
net-pop
|
34
|
+
net-smtp
|
29
35
|
rails-dom-testing (~> 2.0)
|
30
|
-
actionpack (
|
31
|
-
actionview (=
|
32
|
-
activesupport (=
|
33
|
-
rack (~> 2.0, >= 2.
|
36
|
+
actionpack (7.0.8.6)
|
37
|
+
actionview (= 7.0.8.6)
|
38
|
+
activesupport (= 7.0.8.6)
|
39
|
+
rack (~> 2.0, >= 2.2.4)
|
34
40
|
rack-test (>= 0.6.3)
|
35
41
|
rails-dom-testing (~> 2.0)
|
36
42
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
-
actiontext (
|
38
|
-
actionpack (=
|
39
|
-
activerecord (=
|
40
|
-
activestorage (=
|
41
|
-
activesupport (=
|
43
|
+
actiontext (7.0.8.6)
|
44
|
+
actionpack (= 7.0.8.6)
|
45
|
+
activerecord (= 7.0.8.6)
|
46
|
+
activestorage (= 7.0.8.6)
|
47
|
+
activesupport (= 7.0.8.6)
|
48
|
+
globalid (>= 0.6.0)
|
42
49
|
nokogiri (>= 1.8.5)
|
43
|
-
actionview (
|
44
|
-
activesupport (=
|
50
|
+
actionview (7.0.8.6)
|
51
|
+
activesupport (= 7.0.8.6)
|
45
52
|
builder (~> 3.1)
|
46
53
|
erubi (~> 1.4)
|
47
54
|
rails-dom-testing (~> 2.0)
|
48
55
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
-
activejob (
|
50
|
-
activesupport (=
|
56
|
+
activejob (7.0.8.6)
|
57
|
+
activesupport (= 7.0.8.6)
|
51
58
|
globalid (>= 0.3.6)
|
52
|
-
activemodel (
|
53
|
-
activesupport (=
|
54
|
-
activerecord (
|
55
|
-
activemodel (=
|
56
|
-
activesupport (=
|
57
|
-
activestorage (
|
58
|
-
actionpack (=
|
59
|
-
activejob (=
|
60
|
-
activerecord (=
|
61
|
-
activesupport (=
|
59
|
+
activemodel (7.0.8.6)
|
60
|
+
activesupport (= 7.0.8.6)
|
61
|
+
activerecord (7.0.8.6)
|
62
|
+
activemodel (= 7.0.8.6)
|
63
|
+
activesupport (= 7.0.8.6)
|
64
|
+
activestorage (7.0.8.6)
|
65
|
+
actionpack (= 7.0.8.6)
|
66
|
+
activejob (= 7.0.8.6)
|
67
|
+
activerecord (= 7.0.8.6)
|
68
|
+
activesupport (= 7.0.8.6)
|
62
69
|
marcel (~> 1.0)
|
63
70
|
mini_mime (>= 1.1.0)
|
64
|
-
activesupport (
|
71
|
+
activesupport (7.0.8.6)
|
65
72
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
73
|
i18n (>= 1.6, < 2)
|
67
74
|
minitest (>= 5.1)
|
68
75
|
tzinfo (~> 2.0)
|
69
|
-
zeitwerk (~> 2.3)
|
70
76
|
appraisal (2.5.0)
|
71
77
|
bundler
|
72
78
|
rake
|
@@ -94,10 +100,10 @@ GEM
|
|
94
100
|
eventmachine (1.2.7)
|
95
101
|
globalid (1.2.1)
|
96
102
|
activesupport (>= 6.1)
|
97
|
-
i18n (1.14.
|
103
|
+
i18n (1.14.6)
|
98
104
|
concurrent-ruby (~> 1.0)
|
99
105
|
json (2.7.2)
|
100
|
-
loofah (2.
|
106
|
+
loofah (2.23.1)
|
101
107
|
crass (~> 1.0.2)
|
102
108
|
nokogiri (>= 1.12.0)
|
103
109
|
mail (2.8.1)
|
@@ -111,7 +117,7 @@ GEM
|
|
111
117
|
mini_portile2 (2.8.7)
|
112
118
|
minitest (5.25.1)
|
113
119
|
mysql2 (0.5.6)
|
114
|
-
net-imap (0.
|
120
|
+
net-imap (0.5.0)
|
115
121
|
date
|
116
122
|
net-protocol
|
117
123
|
net-pop (0.1.2)
|
@@ -120,7 +126,7 @@ GEM
|
|
120
126
|
timeout
|
121
127
|
net-smtp (0.5.0)
|
122
128
|
net-protocol
|
123
|
-
nio4r (2.7.
|
129
|
+
nio4r (2.7.4)
|
124
130
|
nokogiri (1.16.7)
|
125
131
|
mini_portile2 (~> 2.8.2)
|
126
132
|
racc (~> 1.4)
|
@@ -131,24 +137,23 @@ GEM
|
|
131
137
|
byebug (~> 11.0)
|
132
138
|
pry (>= 0.13, < 0.15)
|
133
139
|
racc (1.8.1)
|
134
|
-
rack (2.2.
|
140
|
+
rack (2.2.10)
|
135
141
|
rack-test (2.1.0)
|
136
142
|
rack (>= 1.3)
|
137
|
-
rails (
|
138
|
-
actioncable (=
|
139
|
-
actionmailbox (=
|
140
|
-
actionmailer (=
|
141
|
-
actionpack (=
|
142
|
-
actiontext (=
|
143
|
-
actionview (=
|
144
|
-
activejob (=
|
145
|
-
activemodel (=
|
146
|
-
activerecord (=
|
147
|
-
activestorage (=
|
148
|
-
activesupport (=
|
143
|
+
rails (7.0.8.6)
|
144
|
+
actioncable (= 7.0.8.6)
|
145
|
+
actionmailbox (= 7.0.8.6)
|
146
|
+
actionmailer (= 7.0.8.6)
|
147
|
+
actionpack (= 7.0.8.6)
|
148
|
+
actiontext (= 7.0.8.6)
|
149
|
+
actionview (= 7.0.8.6)
|
150
|
+
activejob (= 7.0.8.6)
|
151
|
+
activemodel (= 7.0.8.6)
|
152
|
+
activerecord (= 7.0.8.6)
|
153
|
+
activestorage (= 7.0.8.6)
|
154
|
+
activesupport (= 7.0.8.6)
|
149
155
|
bundler (>= 1.15.0)
|
150
|
-
railties (=
|
151
|
-
sprockets-rails (>= 2.0.0)
|
156
|
+
railties (= 7.0.8.6)
|
152
157
|
rails-dom-testing (2.2.0)
|
153
158
|
activesupport (>= 5.0.0)
|
154
159
|
minitest
|
@@ -156,12 +161,13 @@ GEM
|
|
156
161
|
rails-html-sanitizer (1.6.0)
|
157
162
|
loofah (~> 2.21)
|
158
163
|
nokogiri (~> 1.14)
|
159
|
-
railties (
|
160
|
-
actionpack (=
|
161
|
-
activesupport (=
|
164
|
+
railties (7.0.8.6)
|
165
|
+
actionpack (= 7.0.8.6)
|
166
|
+
activesupport (= 7.0.8.6)
|
162
167
|
method_source
|
163
168
|
rake (>= 12.2)
|
164
169
|
thor (~> 1.0)
|
170
|
+
zeitwerk (~> 2.5)
|
165
171
|
rake (13.2.1)
|
166
172
|
rspec (3.13.0)
|
167
173
|
rspec-core (~> 3.13.0)
|
@@ -181,17 +187,10 @@ GEM
|
|
181
187
|
json (>= 1.8, < 3)
|
182
188
|
simplecov-html (~> 0.10.0)
|
183
189
|
simplecov-html (0.10.2)
|
184
|
-
sprockets (4.2.1)
|
185
|
-
concurrent-ruby (~> 1.0)
|
186
|
-
rack (>= 2.2.4, < 4)
|
187
|
-
sprockets-rails (3.5.2)
|
188
|
-
actionpack (>= 6.1)
|
189
|
-
activesupport (>= 6.1)
|
190
|
-
sprockets (>= 3.0.0)
|
191
190
|
sync (0.5.0)
|
192
191
|
term-ansicolor (1.11.2)
|
193
192
|
tins (~> 1.0)
|
194
|
-
thor (1.3.
|
193
|
+
thor (1.3.2)
|
195
194
|
timeout (0.4.1)
|
196
195
|
tins (1.33.0)
|
197
196
|
bigdecimal
|
@@ -201,7 +200,7 @@ GEM
|
|
201
200
|
websocket-driver (0.7.6)
|
202
201
|
websocket-extensions (>= 0.1.0)
|
203
202
|
websocket-extensions (0.1.5)
|
204
|
-
zeitwerk (2.6.
|
203
|
+
zeitwerk (2.6.18)
|
205
204
|
|
206
205
|
PLATFORMS
|
207
206
|
ruby
|
data/fibered_mysql2.gemspec
CHANGED
@@ -3,19 +3,10 @@
|
|
3
3
|
require 'em-synchrony'
|
4
4
|
require 'active_model'
|
5
5
|
require 'active_record/errors'
|
6
|
+
require 'active_record/connection_adapters/mysql2_adapter'
|
6
7
|
require 'active_record/connection_adapters/em_mysql2_adapter'
|
7
8
|
|
8
9
|
module FiberedMysql2
|
9
|
-
module FiberedMysql2Adapter_4_2
|
10
|
-
def lease
|
11
|
-
synchronize do
|
12
|
-
unless in_use?
|
13
|
-
@owner = Fiber.current
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
10
|
module FiberedMysql2Adapter_5_2
|
20
11
|
def lease
|
21
12
|
if in_use?
|
@@ -72,11 +63,19 @@ module FiberedMysql2
|
|
72
63
|
end
|
73
64
|
|
74
65
|
class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::EMMysql2Adapter
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
66
|
+
include FiberedMysql2Adapter_5_2
|
67
|
+
|
68
|
+
class << self
|
69
|
+
# Copied from Mysql2Adapter, except with the EM Mysql2 client
|
70
|
+
def new_client(config)
|
71
|
+
Mysql2::EM::Client.new(config)
|
72
|
+
rescue Mysql2::Error => error
|
73
|
+
if error.error_number == 1049
|
74
|
+
raise ActiveRecord::NoDatabaseError.new, error.message
|
75
|
+
else
|
76
|
+
raise ActiveRecord::ConnectionNotEstablished, error.message
|
77
|
+
end
|
78
|
+
end
|
80
79
|
end
|
81
80
|
|
82
81
|
def initialize(*args)
|
@@ -186,25 +186,6 @@ module FiberedMysql2
|
|
186
186
|
module FiberedDatabaseConnectionPool
|
187
187
|
include FiberedMonitorMixin
|
188
188
|
|
189
|
-
module Adapter_4_2
|
190
|
-
def cached_connections
|
191
|
-
@reserved_connections
|
192
|
-
end
|
193
|
-
|
194
|
-
def current_connection_id
|
195
|
-
ActiveRecord::Base.connection_id ||= Fiber.current.object_id
|
196
|
-
end
|
197
|
-
|
198
|
-
def checkout
|
199
|
-
begin
|
200
|
-
reap_connections
|
201
|
-
rescue => ex
|
202
|
-
ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
|
203
|
-
end
|
204
|
-
super
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
189
|
module Adapter_5_2
|
209
190
|
def cached_connections
|
210
191
|
@thread_cached_conns
|
@@ -229,27 +210,16 @@ module FiberedMysql2
|
|
229
210
|
end
|
230
211
|
end
|
231
212
|
end
|
213
|
+
include Adapter_5_2
|
232
214
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
when 5, 6
|
237
|
-
include Adapter_5_2
|
238
|
-
end
|
239
|
-
|
240
|
-
def initialize(connection_spec, *args, **keyword_args)
|
241
|
-
if ActiveRecord.gem_version < "6.1"
|
242
|
-
connection_spec.config[:reaping_frequency] and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
|
243
|
-
connection_spec.config[:reaping_frequency] = nil # starting in Rails 5, this defaults to 60 if not explicitly set
|
244
|
-
elsif connection_spec.db_config.reaping_frequency
|
245
|
-
connection_spec.db_config.reaping_frequency > 0 and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
|
215
|
+
def initialize(pool_config)
|
216
|
+
if pool_config.db_config.reaping_frequency
|
217
|
+
pool_config.db_config.reaping_frequency > 0 and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
|
246
218
|
end
|
247
219
|
|
248
|
-
super(
|
220
|
+
super(pool_config)
|
249
221
|
|
250
222
|
@reaper = nil # no need to keep a reference to this since it does nothing in this sub-class
|
251
|
-
|
252
|
-
# note that @reserved_connections is a ThreadSafe::Cache which is overkill in a fibered world, but harmless
|
253
223
|
end
|
254
224
|
|
255
225
|
def connection
|
@@ -16,90 +16,80 @@ module EM::Synchrony
|
|
16
16
|
|
17
17
|
_ = TransactionManager
|
18
18
|
class TransactionManager < _
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
else
|
44
|
-
::ActiveRecord::ConnectionAdapters::SavepointTransaction.new(@connection, "active_record_#{Fiber.current.object_id}_#{open_transactions}", _current_stack.last, **options, run_commit_callbacks: run_commit_callbacks)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
if @connection.supports_lazy_transactions? && lazy_transactions_enabled? && options[:_lazy] != false
|
49
|
-
@has_unmaterialized_transactions = true
|
50
|
-
else
|
51
|
-
transaction.materialize!
|
52
|
-
end
|
53
|
-
_current_stack.push(transaction)
|
54
|
-
transaction
|
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!
|
55
43
|
end
|
44
|
+
_current_stack.push(transaction)
|
45
|
+
transaction
|
56
46
|
end
|
47
|
+
end
|
57
48
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
72
|
-
@has_unmaterialized_transactions = false
|
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
|
73
62
|
end
|
63
|
+
@has_unmaterialized_transactions = false
|
74
64
|
end
|
65
|
+
end
|
75
66
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
transaction.commit
|
90
|
-
transaction.commit_records
|
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
|
91
78
|
end
|
79
|
+
|
80
|
+
transaction.commit
|
81
|
+
transaction.commit_records
|
92
82
|
end
|
83
|
+
end
|
93
84
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
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
|
103
93
|
end
|
104
94
|
end
|
105
95
|
end
|
@@ -111,23 +101,17 @@ module FiberedMysql2
|
|
111
101
|
module FiberedMysql2ConnectionFactory
|
112
102
|
def fibered_mysql2_connection(raw_config)
|
113
103
|
config = raw_config.symbolize_keys
|
104
|
+
config[:flags] ||= 0
|
114
105
|
|
106
|
+
if config[:flags].kind_of? Array
|
107
|
+
config[:flags].push "FOUND_ROWS"
|
108
|
+
else
|
109
|
+
config[:flags] |= Mysql2::Client::FOUND_ROWS
|
110
|
+
end
|
115
111
|
config[:username] = 'root' if config[:username].nil?
|
116
|
-
config[:flags] = Mysql2::Client::FOUND_ROWS if Mysql2::Client.const_defined?(:FOUND_ROWS)
|
117
|
-
|
118
|
-
client =
|
119
|
-
begin
|
120
|
-
Mysql2::EM::Client.new(config)
|
121
|
-
rescue Mysql2::Error => error
|
122
|
-
if error.message.include?("Unknown database")
|
123
|
-
raise ActiveRecord::NoDatabaseError.new(error.message, error)
|
124
|
-
else
|
125
|
-
raise
|
126
|
-
end
|
127
|
-
end
|
128
112
|
|
129
|
-
|
130
|
-
FiberedMysql2Adapter.new(client, logger,
|
113
|
+
client = FiberedMysql2Adapter.new_client(config)
|
114
|
+
FiberedMysql2Adapter.new(client, logger, nil, config)
|
131
115
|
end
|
132
116
|
end
|
133
117
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_record/database_configurations/hash_config"
|
4
|
+
|
3
5
|
module FiberedMysql2
|
4
6
|
module HashConfigOverride
|
5
7
|
# Override the reaping_frequency method to return nil so that the connection pool does not reap connections when in fibered mode.
|
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.3.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: 2024-
|
11
|
+
date: 2024-10-31 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: '6.1'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '7'
|
36
|
+
version: '7.1'
|
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: '6.1'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '7'
|
46
|
+
version: '7.1'
|
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_0.gemfile
|
70
69
|
- gemfiles/rails_6_1.gemfile
|
70
|
+
- gemfiles/rails_7_0.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
|