fibered_mysql2 0.3.0 → 0.3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b26f8b41b8008965bde3defa980553ef3f5ee82dc750d510f98d1728db1dfb2b
4
- data.tar.gz: 8a6ff673f5be6e742bb010c217061a78012206d515cd2450efaf17159d208d90
3
+ metadata.gz: 6d5ffddcba35cf6e56e907a78223d599cfb8059b3886b1e323f51a79a58ebe04
4
+ data.tar.gz: 29ab8df4fb4fc505ae38a30e2c8b2cac14b950d84abf974368b1217608a7553c
5
5
  SHA512:
6
- metadata.gz: a2f5e70e6f236fcd7fea48e50bc09e33571d2d301e0f1eaa204f90d04e22fbd80585de33c3afd1dea13dea40076a56a158e2e39eeed7203c4b6c6b79b5a6fce4
7
- data.tar.gz: 3b5e28792b82a53a7c43e937b30d953617c31399c6a34a74aba2e8d8e454661dc9a2c19728e6ccffa21b6e1a8481052073ccc48f2db84567baa5fb4bfe2b6707
6
+ metadata.gz: 9abc62b6d6325399935a9ad810dc409a46d5e280b5e486162e643f0473ac25cb58c0ef6afb42e7cfc059fb3fc4cf3656816807bf8efb1a37850712e6599a28b1
7
+ data.tar.gz: dfcb809f7520a877ae022636d6f0ff846849c3af20ecc7529691b811c483b96192394e8518c3c3769124998c2d54f88a428196276847f61741031c1a3f05e36b
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: FiberedMySQL2 Gem Build
3
- on: [push, pull_request]
3
+ on: [push]
4
4
  jobs:
5
5
  test:
6
6
  name: Unit Tests
@@ -11,7 +11,6 @@ jobs:
11
11
  ruby: [3.1, 3.2, 3.3]
12
12
  gemfile:
13
13
  - Gemfile
14
- - gemfiles/rails_6_1.gemfile
15
14
  - gemfiles/rails_7_0.gemfile
16
15
  env:
17
16
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
data/Appraisals CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "appraisal/matrix"
4
4
 
5
- appraisal_matrix(rails: [">= 6.1", "< 7.1"])
5
+ appraisal_matrix(rails: [">= 7.0", "< 7.1"])
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ 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
+
7
11
  ## [0.3.0] - 2024-10-23
8
12
  ### Added
9
13
  - Support for Rails 7.0.
data/Gemfile CHANGED
@@ -7,7 +7,6 @@ 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'
data/Gemfile.lock CHANGED
@@ -1,74 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (0.3.0)
4
+ fibered_mysql2 (0.3.2.pre.tstarck.1)
5
5
  em-synchrony (~> 1.0)
6
- rails (>= 6.1, < 7.1)
6
+ rails (>= 7.0, < 7.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.8.5)
12
- actionpack (= 7.0.8.5)
13
- activesupport (= 7.0.8.5)
11
+ actioncable (7.0.8.7)
12
+ actionpack (= 7.0.8.7)
13
+ activesupport (= 7.0.8.7)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.8.5)
17
- actionpack (= 7.0.8.5)
18
- activejob (= 7.0.8.5)
19
- activerecord (= 7.0.8.5)
20
- activestorage (= 7.0.8.5)
21
- activesupport (= 7.0.8.5)
16
+ actionmailbox (7.0.8.7)
17
+ actionpack (= 7.0.8.7)
18
+ activejob (= 7.0.8.7)
19
+ activerecord (= 7.0.8.7)
20
+ activestorage (= 7.0.8.7)
21
+ activesupport (= 7.0.8.7)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.0.8.5)
27
- actionpack (= 7.0.8.5)
28
- actionview (= 7.0.8.5)
29
- activejob (= 7.0.8.5)
30
- activesupport (= 7.0.8.5)
26
+ actionmailer (7.0.8.7)
27
+ actionpack (= 7.0.8.7)
28
+ actionview (= 7.0.8.7)
29
+ activejob (= 7.0.8.7)
30
+ activesupport (= 7.0.8.7)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.8.5)
37
- actionview (= 7.0.8.5)
38
- activesupport (= 7.0.8.5)
36
+ actionpack (7.0.8.7)
37
+ actionview (= 7.0.8.7)
38
+ activesupport (= 7.0.8.7)
39
39
  rack (~> 2.0, >= 2.2.4)
40
40
  rack-test (>= 0.6.3)
41
41
  rails-dom-testing (~> 2.0)
42
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.8.5)
44
- actionpack (= 7.0.8.5)
45
- activerecord (= 7.0.8.5)
46
- activestorage (= 7.0.8.5)
47
- activesupport (= 7.0.8.5)
43
+ actiontext (7.0.8.7)
44
+ actionpack (= 7.0.8.7)
45
+ activerecord (= 7.0.8.7)
46
+ activestorage (= 7.0.8.7)
47
+ activesupport (= 7.0.8.7)
48
48
  globalid (>= 0.6.0)
49
49
  nokogiri (>= 1.8.5)
50
- actionview (7.0.8.5)
51
- activesupport (= 7.0.8.5)
50
+ actionview (7.0.8.7)
51
+ activesupport (= 7.0.8.7)
52
52
  builder (~> 3.1)
53
53
  erubi (~> 1.4)
54
54
  rails-dom-testing (~> 2.0)
55
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.8.5)
57
- activesupport (= 7.0.8.5)
56
+ activejob (7.0.8.7)
57
+ activesupport (= 7.0.8.7)
58
58
  globalid (>= 0.3.6)
59
- activemodel (7.0.8.5)
60
- activesupport (= 7.0.8.5)
61
- activerecord (7.0.8.5)
62
- activemodel (= 7.0.8.5)
63
- activesupport (= 7.0.8.5)
64
- activestorage (7.0.8.5)
65
- actionpack (= 7.0.8.5)
66
- activejob (= 7.0.8.5)
67
- activerecord (= 7.0.8.5)
68
- activesupport (= 7.0.8.5)
59
+ activemodel (7.0.8.7)
60
+ activesupport (= 7.0.8.7)
61
+ activerecord (7.0.8.7)
62
+ activemodel (= 7.0.8.7)
63
+ activesupport (= 7.0.8.7)
64
+ activestorage (7.0.8.7)
65
+ actionpack (= 7.0.8.7)
66
+ activejob (= 7.0.8.7)
67
+ activerecord (= 7.0.8.7)
68
+ activesupport (= 7.0.8.7)
69
69
  marcel (~> 1.0)
70
70
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.8.5)
71
+ activesupport (7.0.8.7)
72
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
73
  i18n (>= 1.6, < 2)
74
74
  minitest (>= 5.1)
@@ -79,31 +79,23 @@ GEM
79
79
  thor (>= 0.14.0)
80
80
  appraisal-matrix (0.3.0)
81
81
  appraisal (~> 2.2)
82
- bigdecimal (3.1.8)
82
+ base64 (0.3.0)
83
83
  builder (3.3.0)
84
- byebug (11.1.3)
84
+ byebug (12.0.0)
85
85
  coderay (1.1.3)
86
- concurrent-ruby (1.3.4)
87
- coveralls (0.8.23)
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)
86
+ concurrent-ruby (1.3.5)
93
87
  crass (1.0.6)
94
- date (3.3.4)
95
- diff-lcs (1.5.1)
96
- docile (1.4.1)
88
+ date (3.4.1)
89
+ diff-lcs (1.6.2)
97
90
  em-synchrony (1.0.6)
98
91
  eventmachine (>= 1.0.0.beta.1)
99
- erubi (1.13.0)
92
+ erubi (1.13.1)
100
93
  eventmachine (1.2.7)
101
94
  globalid (1.2.1)
102
95
  activesupport (>= 6.1)
103
- i18n (1.14.6)
96
+ i18n (1.14.7)
104
97
  concurrent-ruby (~> 1.0)
105
- json (2.7.2)
106
- loofah (2.22.0)
98
+ loofah (2.24.1)
107
99
  crass (~> 1.0.2)
108
100
  nokogiri (>= 1.12.0)
109
101
  mail (2.8.1)
@@ -114,90 +106,80 @@ GEM
114
106
  marcel (1.0.4)
115
107
  method_source (1.1.0)
116
108
  mini_mime (1.1.5)
117
- mini_portile2 (2.8.7)
118
- minitest (5.25.1)
109
+ mini_portile2 (2.8.9)
110
+ minitest (5.25.5)
119
111
  mysql2 (0.5.6)
120
- net-imap (0.5.0)
112
+ net-imap (0.5.9)
121
113
  date
122
114
  net-protocol
123
115
  net-pop (0.1.2)
124
116
  net-protocol
125
117
  net-protocol (0.2.2)
126
118
  timeout
127
- net-smtp (0.5.0)
119
+ net-smtp (0.5.1)
128
120
  net-protocol
129
- nio4r (2.7.3)
130
- nokogiri (1.16.7)
121
+ nio4r (2.7.4)
122
+ nokogiri (1.18.9)
131
123
  mini_portile2 (~> 2.8.2)
132
124
  racc (~> 1.4)
133
- pry (0.14.2)
125
+ pry (0.15.2)
134
126
  coderay (~> 1.1)
135
127
  method_source (~> 1.0)
136
- pry-byebug (3.10.1)
137
- byebug (~> 11.0)
138
- pry (>= 0.13, < 0.15)
128
+ pry-byebug (3.11.0)
129
+ byebug (~> 12.0)
130
+ pry (>= 0.13, < 0.16)
139
131
  racc (1.8.1)
140
- rack (2.2.10)
141
- rack-test (2.1.0)
132
+ rack (2.2.17)
133
+ rack-test (2.2.0)
142
134
  rack (>= 1.3)
143
- rails (7.0.8.5)
144
- actioncable (= 7.0.8.5)
145
- actionmailbox (= 7.0.8.5)
146
- actionmailer (= 7.0.8.5)
147
- actionpack (= 7.0.8.5)
148
- actiontext (= 7.0.8.5)
149
- actionview (= 7.0.8.5)
150
- activejob (= 7.0.8.5)
151
- activemodel (= 7.0.8.5)
152
- activerecord (= 7.0.8.5)
153
- activestorage (= 7.0.8.5)
154
- activesupport (= 7.0.8.5)
135
+ rails (7.0.8.7)
136
+ actioncable (= 7.0.8.7)
137
+ actionmailbox (= 7.0.8.7)
138
+ actionmailer (= 7.0.8.7)
139
+ actionpack (= 7.0.8.7)
140
+ actiontext (= 7.0.8.7)
141
+ actionview (= 7.0.8.7)
142
+ activejob (= 7.0.8.7)
143
+ activemodel (= 7.0.8.7)
144
+ activerecord (= 7.0.8.7)
145
+ activestorage (= 7.0.8.7)
146
+ activesupport (= 7.0.8.7)
155
147
  bundler (>= 1.15.0)
156
- railties (= 7.0.8.5)
157
- rails-dom-testing (2.2.0)
148
+ railties (= 7.0.8.7)
149
+ rails-dom-testing (2.3.0)
158
150
  activesupport (>= 5.0.0)
159
151
  minitest
160
152
  nokogiri (>= 1.6)
161
- rails-html-sanitizer (1.6.0)
153
+ rails-html-sanitizer (1.6.2)
162
154
  loofah (~> 2.21)
163
- nokogiri (~> 1.14)
164
- railties (7.0.8.5)
165
- actionpack (= 7.0.8.5)
166
- activesupport (= 7.0.8.5)
155
+ 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)
156
+ railties (7.0.8.7)
157
+ actionpack (= 7.0.8.7)
158
+ activesupport (= 7.0.8.7)
167
159
  method_source
168
160
  rake (>= 12.2)
169
161
  thor (~> 1.0)
170
162
  zeitwerk (~> 2.5)
171
- rake (13.2.1)
172
- rspec (3.13.0)
163
+ rake (13.3.0)
164
+ rspec (3.13.1)
173
165
  rspec-core (~> 3.13.0)
174
166
  rspec-expectations (~> 3.13.0)
175
167
  rspec-mocks (~> 3.13.0)
176
- rspec-core (3.13.0)
168
+ rspec-core (3.13.5)
177
169
  rspec-support (~> 3.13.0)
178
- rspec-expectations (3.13.1)
170
+ rspec-expectations (3.13.5)
179
171
  diff-lcs (>= 1.2.0, < 2.0)
180
172
  rspec-support (~> 3.13.0)
181
- rspec-mocks (3.13.1)
173
+ rspec-mocks (3.13.5)
182
174
  diff-lcs (>= 1.2.0, < 2.0)
183
175
  rspec-support (~> 3.13.0)
184
- rspec-support (3.13.1)
185
- simplecov (0.16.1)
186
- docile (~> 1.1)
187
- json (>= 1.8, < 3)
188
- simplecov-html (~> 0.10.0)
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
176
+ rspec-support (3.13.4)
177
+ thor (1.4.0)
178
+ timeout (0.4.3)
198
179
  tzinfo (2.0.6)
199
180
  concurrent-ruby (~> 1.0)
200
- websocket-driver (0.7.6)
181
+ websocket-driver (0.8.0)
182
+ base64
201
183
  websocket-extensions (>= 0.1.0)
202
184
  websocket-extensions (0.1.5)
203
185
  zeitwerk (2.6.18)
@@ -208,7 +190,6 @@ PLATFORMS
208
190
  DEPENDENCIES
209
191
  appraisal
210
192
  appraisal-matrix
211
- coveralls
212
193
  fibered_mysql2!
213
194
  mysql2 (~> 0.5)
214
195
  nokogiri
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency 'em-synchrony', '~> 1.0'
33
- spec.add_dependency 'rails', '>= 6.1', '< 7.1'
33
+ spec.add_dependency 'rails', '>= 7.0', '< 7.1'
34
34
  end
@@ -3,7 +3,8 @@
3
3
  require 'em-synchrony'
4
4
  require 'active_model'
5
5
  require 'active_record/errors'
6
- require 'active_record/connection_adapters/em_mysql2_adapter'
6
+ require 'active_record/connection_adapters/mysql2_adapter'
7
+ require 'em-synchrony/mysql2'
7
8
 
8
9
  module FiberedMysql2
9
10
  module FiberedMysql2Adapter_5_2
@@ -61,20 +62,17 @@ module FiberedMysql2
61
62
  end
62
63
  end
63
64
 
64
- class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::EMMysql2Adapter
65
+ class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
65
66
  include FiberedMysql2Adapter_5_2
67
+ include FiberedMysql2::TransactionManagerOverride
66
68
 
67
69
  class << self
68
70
  # Copied from Mysql2Adapter, except with the EM Mysql2 client
69
71
  def new_client(config)
70
72
  Mysql2::EM::Client.new(config)
71
73
  rescue Mysql2::Error => error
72
- if error.error_number == ConnectionAdapters::Mysql2Adapter::ER_BAD_DB_ERROR
73
- raise ActiveRecord::NoDatabaseError.db_error(config[:database])
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])
74
+ if error.error_number == 1049
75
+ raise ActiveRecord::NoDatabaseError.new, error.message
78
76
  else
79
77
  raise ActiveRecord::ConnectionNotEstablished, error.message
80
78
  end
@@ -248,13 +248,6 @@ module FiberedMysql2
248
248
 
249
249
  private
250
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
256
- end
257
-
258
251
  def current_thread
259
252
  Fiber.current
260
253
  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)
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_record"
4
+
5
+ module FiberedMysql2
6
+ module TransactionManagerOverride
7
+ class TransactionManager < ::ActiveRecord::ConnectionAdapters::TransactionManager
8
+ def initialize(*args)
9
+ super
10
+ @stack = Hash.new { |h, k| h[k] = [] }
11
+ end
12
+
13
+ def current_transaction #:nodoc:
14
+ _current_stack.last || NULL_TRANSACTION
15
+ end
16
+
17
+ def open_transactions
18
+ _current_stack.size
19
+ end
20
+
21
+ def begin_transaction(isolation: nil, joinable: true, _lazy: true)
22
+ @connection.lock.synchronize do
23
+ run_commit_callbacks = !current_transaction.joinable?
24
+ transaction =
25
+ if _current_stack.empty?
26
+ ::ActiveRecord::ConnectionAdapters::RealTransaction.new(@connection, isolation:, joinable:, run_commit_callbacks: run_commit_callbacks)
27
+ else
28
+ ::ActiveRecord::ConnectionAdapters::SavepointTransaction.new(@connection, "active_record_#{Fiber.current.object_id}_#{open_transactions}", _current_stack.last, isolation:, joinable:, run_commit_callbacks: run_commit_callbacks)
29
+ end
30
+
31
+ if @connection.supports_lazy_transactions? && lazy_transactions_enabled? && _lazy
32
+ @has_unmaterialized_transactions = true
33
+ else
34
+ transaction.materialize!
35
+ end
36
+ _current_stack.push(transaction)
37
+ transaction
38
+ end
39
+ end
40
+
41
+ # Overriding the ActiveRecord::TransactionManager#materialize_transactions method to use
42
+ # fiber safe the _current_stack instead of the @stack instance variable. when marterializing
43
+ # transactions.
44
+ def materialize_transactions
45
+ return if @materializing_transactions
46
+ return unless @has_unmaterialized_transactions
47
+
48
+ @connection.lock.synchronize do
49
+ begin
50
+ @materializing_transactions = true
51
+ _current_stack.each { |t| t.materialize! unless t.materialized? }
52
+ ensure
53
+ @materializing_transactions = false
54
+ end
55
+ @has_unmaterialized_transactions = false
56
+ end
57
+ end
58
+
59
+ # Overriding the ActiveRecord::TransactionManager#commit_transaction method to use
60
+ # fiber safe the _current_stack instead of the @stack instance variable. when marterializing
61
+ # transactions.
62
+ def commit_transaction
63
+ @connection.lock.synchronize do
64
+ transaction = _current_stack.last
65
+
66
+ begin
67
+ transaction.before_commit_records
68
+ ensure
69
+ _current_stack.pop
70
+ end
71
+
72
+ transaction.commit
73
+ transaction.commit_records
74
+ end
75
+ end
76
+
77
+ # Overriding the ActiveRecord::TransactionManager#rollback_transaction method to use
78
+ # fiber safe the _current_stack instead of the @stack instance variable. when marterializing
79
+ # transactions.
80
+ def rollback_transaction(transaction = nil)
81
+ @connection.lock.synchronize do
82
+ transaction ||= _current_stack.pop
83
+ transaction.rollback
84
+ transaction.rollback_records
85
+ end
86
+ end
87
+
88
+ private
89
+
90
+ def _current_stack
91
+ @stack[Fiber.current.object_id]
92
+ end
93
+ end
94
+
95
+ def reset_transaction #:nodoc:
96
+ @transaction_manager = ::FiberedMysql2::TransactionManagerOverride::TransactionManager.new(self)
97
+ end
98
+ end
99
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2.pre.tstarck.1"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fibered_mysql2/version'
4
+ require 'fibered_mysql2/transaction_manager_override'
4
5
  require_relative '../lib/active_record/connection_adapters/fibered_mysql2_adapter'
5
6
  require 'fibered_mysql2/fibered_database_connection_pool'
6
7
  require 'fibered_mysql2/fibered_mutex_with_waiter_priority'
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.3.0
4
+ version: 0.3.2.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: 2024-10-23 00:00:00.000000000 Z
11
+ date: 2025-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-synchrony
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
33
+ version: '7.0'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '7.1'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '6.1'
43
+ version: '7.0'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '7.1'
@@ -66,7 +66,6 @@ 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
71
70
  - lib/active_record/connection_adapters/fibered_mysql2_adapter.rb
72
71
  - lib/fibered_mysql2.rb
@@ -74,6 +73,7 @@ files:
74
73
  - lib/fibered_mysql2/fibered_mutex_with_waiter_priority.rb
75
74
  - lib/fibered_mysql2/fibered_mysql2_connection_factory.rb
76
75
  - lib/fibered_mysql2/hash_config_override.rb
76
+ - lib/fibered_mysql2/transaction_manager_override.rb
77
77
  - lib/fibered_mysql2/version.rb
78
78
  homepage: https://github.com/Invoca/fibered_mysql2
79
79
  licenses: []
@@ -91,9 +91,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - ">"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.3.1
97
97
  requirements: []
98
98
  rubygems_version: 3.3.27
99
99
  signing_key:
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "appraisal-matrix"
7
- gem "coveralls", require: false
8
- gem "mysql2", "~> 0.5"
9
- gem "nokogiri"
10
- gem "pry"
11
- gem "pry-byebug"
12
- gem "rake"
13
- gem "rspec"
14
- gem "rails", "~> 6.1.0"
15
-
16
- gemspec path: "../"