fibered_mysql2 0.3.2.pre.tstarck.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14341c3b793112061aa9934a52cebb26ce5f109873ad66d6c73956377392df75
4
- data.tar.gz: 1b571b948cc5823906ca438a4cb43edc0c2a3a606441160a5263ac0aa10f3b22
3
+ metadata.gz: f4de2661b6a53134802496ea91ed73ad10623ee8459f1d4ecdb1ebdef6ea4f63
4
+ data.tar.gz: 8846ea290e1ed8ccab648c55458809b63cb4a1ca737f405f0ece815b441104cf
5
5
  SHA512:
6
- metadata.gz: 074ee670599ad1e31ede07877e3b2956e6e99d332c19bea36d3f32b257523c8d99b7c23ce5ede83ec45085ecb3162960f170c3c0e27796905203c63c32dabd7d
7
- data.tar.gz: 3a26877200c88facb93a1dabd2bb069af8d2c8bcffa0299258c6503259dc47fb4e2503b0194f1946d6cf160c7699be10cbbb4874f681514ab221fb45320d2c15
6
+ metadata.gz: 68e08cebe9eec799298274fa1be5e3f83f7b896b5cbdebad3b3b5cb082fabb92388b80310cdb8bd376605374db8460dad4f9fde4746385d9e9d03f53278bf0a2
7
+ data.tar.gz: 1ea97ac7495a0bc0085aaf4f45e226ad9110f879d893673ae646c48753f90f4c456156bb29ca63c36ddf827fff96a7aab934f80d43c27dbc534fd602db8472be
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: FiberedMySQL2 Gem Build
3
- on: [push]
3
+ on: [push, pull_request]
4
4
  jobs:
5
5
  test:
6
6
  name: Unit Tests
@@ -8,7 +8,7 @@ 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
14
  - gemfiles/rails_7_0.gemfile
@@ -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.6
1
+ 3.3.8
data/Appraisals CHANGED
@@ -2,4 +2,10 @@
2
2
 
3
3
  require "appraisal/matrix"
4
4
 
5
- appraisal_matrix(rails: [">= 7.0", "< 7.2"])
5
+ appraisal_matrix(rails: [">= 7.0", "< 7.2"]) do |rails:|
6
+ if rails < "7.1"
7
+ gem "mutex_m"
8
+ gem "base64"
9
+ gem "bigdecimal"
10
+ end
11
+ end
data/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ 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
+
7
24
  ## [0.3.1] - 2024-10-30
8
25
  ### Fixed
9
26
  - Fixed bug in FiberedMysqlAdapter.new_client that was causing `uninitialized constant` errors.
data/Gemfile CHANGED
@@ -12,4 +12,4 @@ gem 'nokogiri'
12
12
  gem 'pry'
13
13
  gem 'pry-byebug'
14
14
  gem 'rake'
15
- gem 'rspec', '< 3.13'
15
+ gem 'rspec', '~> 3.12.0' # Rspec 3.13 is causing segfaults for some reason in CI...
data/Gemfile.lock CHANGED
@@ -1,42 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fibered_mysql2 (0.3.2.pre.tstarck.7)
4
+ fibered_mysql2 (0.4.0.pre.tstarck.1)
5
5
  em-synchrony (~> 1.0)
6
6
  rails (>= 7.0, < 7.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.1.5.2)
12
- actionpack (= 7.1.5.2)
13
- activesupport (= 7.1.5.2)
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
16
  zeitwerk (~> 2.6)
17
- actionmailbox (7.1.5.2)
18
- actionpack (= 7.1.5.2)
19
- activejob (= 7.1.5.2)
20
- activerecord (= 7.1.5.2)
21
- activestorage (= 7.1.5.2)
22
- activesupport (= 7.1.5.2)
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)
23
23
  mail (>= 2.7.1)
24
24
  net-imap
25
25
  net-pop
26
26
  net-smtp
27
- actionmailer (7.1.5.2)
28
- actionpack (= 7.1.5.2)
29
- actionview (= 7.1.5.2)
30
- activejob (= 7.1.5.2)
31
- activesupport (= 7.1.5.2)
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)
32
32
  mail (~> 2.5, >= 2.5.4)
33
33
  net-imap
34
34
  net-pop
35
35
  net-smtp
36
36
  rails-dom-testing (~> 2.2)
37
- actionpack (7.1.5.2)
38
- actionview (= 7.1.5.2)
39
- activesupport (= 7.1.5.2)
37
+ actionpack (7.1.5.1)
38
+ actionview (= 7.1.5.1)
39
+ activesupport (= 7.1.5.1)
40
40
  nokogiri (>= 1.8.5)
41
41
  racc
42
42
  rack (>= 2.2.4)
@@ -44,35 +44,35 @@ GEM
44
44
  rack-test (>= 0.6.3)
45
45
  rails-dom-testing (~> 2.2)
46
46
  rails-html-sanitizer (~> 1.6)
47
- actiontext (7.1.5.2)
48
- actionpack (= 7.1.5.2)
49
- activerecord (= 7.1.5.2)
50
- activestorage (= 7.1.5.2)
51
- activesupport (= 7.1.5.2)
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)
52
52
  globalid (>= 0.6.0)
53
53
  nokogiri (>= 1.8.5)
54
- actionview (7.1.5.2)
55
- activesupport (= 7.1.5.2)
54
+ actionview (7.1.5.1)
55
+ activesupport (= 7.1.5.1)
56
56
  builder (~> 3.1)
57
57
  erubi (~> 1.11)
58
58
  rails-dom-testing (~> 2.2)
59
59
  rails-html-sanitizer (~> 1.6)
60
- activejob (7.1.5.2)
61
- activesupport (= 7.1.5.2)
60
+ activejob (7.1.5.1)
61
+ activesupport (= 7.1.5.1)
62
62
  globalid (>= 0.3.6)
63
- activemodel (7.1.5.2)
64
- activesupport (= 7.1.5.2)
65
- activerecord (7.1.5.2)
66
- activemodel (= 7.1.5.2)
67
- activesupport (= 7.1.5.2)
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
68
  timeout (>= 0.4.0)
69
- activestorage (7.1.5.2)
70
- actionpack (= 7.1.5.2)
71
- activejob (= 7.1.5.2)
72
- activerecord (= 7.1.5.2)
73
- activesupport (= 7.1.5.2)
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)
74
74
  marcel (~> 1.0)
75
- activesupport (7.1.5.2)
75
+ activesupport (7.1.5.1)
76
76
  base64
77
77
  benchmark (>= 0.3)
78
78
  bigdecimal
@@ -169,20 +169,20 @@ GEM
169
169
  rack (>= 1.3)
170
170
  rackup (2.2.1)
171
171
  rack (>= 3)
172
- rails (7.1.5.2)
173
- actioncable (= 7.1.5.2)
174
- actionmailbox (= 7.1.5.2)
175
- actionmailer (= 7.1.5.2)
176
- actionpack (= 7.1.5.2)
177
- actiontext (= 7.1.5.2)
178
- actionview (= 7.1.5.2)
179
- activejob (= 7.1.5.2)
180
- activemodel (= 7.1.5.2)
181
- activerecord (= 7.1.5.2)
182
- activestorage (= 7.1.5.2)
183
- activesupport (= 7.1.5.2)
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)
184
184
  bundler (>= 1.15.0)
185
- railties (= 7.1.5.2)
185
+ railties (= 7.1.5.1)
186
186
  rails-dom-testing (2.3.0)
187
187
  activesupport (>= 5.0.0)
188
188
  minitest
@@ -190,9 +190,9 @@ GEM
190
190
  rails-html-sanitizer (1.6.2)
191
191
  loofah (~> 2.21)
192
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.2)
194
- actionpack (= 7.1.5.2)
195
- activesupport (= 7.1.5.2)
193
+ railties (7.1.5.1)
194
+ actionpack (= 7.1.5.1)
195
+ activesupport (= 7.1.5.1)
196
196
  irb
197
197
  rackup (>= 1.0.0)
198
198
  rake (>= 12.2)
@@ -208,15 +208,15 @@ GEM
208
208
  rspec-core (~> 3.12.0)
209
209
  rspec-expectations (~> 3.12.0)
210
210
  rspec-mocks (~> 3.12.0)
211
- rspec-core (3.12.2)
211
+ rspec-core (3.12.3)
212
212
  rspec-support (~> 3.12.0)
213
- rspec-expectations (3.12.3)
213
+ rspec-expectations (3.12.4)
214
214
  diff-lcs (>= 1.2.0, < 2.0)
215
215
  rspec-support (~> 3.12.0)
216
- rspec-mocks (3.12.6)
216
+ rspec-mocks (3.12.7)
217
217
  diff-lcs (>= 1.2.0, < 2.0)
218
218
  rspec-support (~> 3.12.0)
219
- rspec-support (3.12.1)
219
+ rspec-support (3.12.2)
220
220
  securerandom (0.4.1)
221
221
  stringio (3.1.7)
222
222
  thor (1.4.0)
@@ -241,7 +241,7 @@ DEPENDENCIES
241
241
  pry
242
242
  pry-byebug
243
243
  rake
244
- rspec (< 3.13)
244
+ rspec (~> 3.12.0)
245
245
 
246
246
  BUNDLED WITH
247
- 2.2.29
247
+ 2.6.9
@@ -9,7 +9,10 @@ gem "nokogiri"
9
9
  gem "pry"
10
10
  gem "pry-byebug"
11
11
  gem "rake"
12
- gem "rspec", "< 3.13"
12
+ gem "rspec", "~> 3.12.0"
13
13
  gem "rails", "~> 7.0.0"
14
+ gem "mutex_m"
15
+ gem "base64"
16
+ gem "bigdecimal"
14
17
 
15
18
  gemspec path: "../"
@@ -9,7 +9,7 @@ gem "nokogiri"
9
9
  gem "pry"
10
10
  gem "pry-byebug"
11
11
  gem "rake"
12
- gem "rspec", "< 3.13"
12
+ gem "rspec", "~> 3.12.0"
13
13
  gem "rails", "~> 7.1.0"
14
14
 
15
15
  gemspec path: "../"
@@ -3,6 +3,7 @@
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'
7
8
  require 'em-synchrony/mysql2'
8
9
 
@@ -62,31 +63,9 @@ module FiberedMysql2
62
63
  end
63
64
  end
64
65
 
65
- module FiberedMysql2Adapter_7_1
66
- def expire
67
- if in_use?
68
- # Because we are actively releasing connections from dead fibers, we only want
69
- # to enforce that we're expiring the current fibers connection, iff the owner
70
- # of the connection is still alive.
71
- if @owner.alive? && @owner != ActiveSupport::IsolatedExecutionState.context
72
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
73
- "it is owned by a different fiber: #{@owner}. " \
74
- "Current fiber: #{ActiveSupport::IsolatedExecutionState.context}."
75
- end
76
-
77
- @idle_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)
78
- @owner = nil
79
- else
80
- raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, it is not currently leased."
81
- end
82
- end
83
- end
84
-
85
66
  class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
86
- if Rails.gem_version < "7.1"
67
+ if ::ActiveRecord.gem_version < "7.1"
87
68
  include FiberedMysql2Adapter_7_0
88
- else
89
- include FiberedMysql2Adapter_7_1
90
69
  end
91
70
 
92
71
  class << self
@@ -184,8 +184,6 @@ module FiberedMysql2
184
184
  end
185
185
 
186
186
  module FiberedDatabaseConnectionPool
187
- include FiberedMonitorMixin
188
-
189
187
  module Adapter_7_0
190
188
  def release_connection(owner_thread = Fiber.current)
191
189
  if (conn = @thread_cached_conns.delete(connection_cache_key(owner_thread)))
@@ -194,7 +192,7 @@ module FiberedMysql2
194
192
  end
195
193
 
196
194
  def with_connection
197
- unless (conn = cached_connections[current_connection_id])
195
+ unless (conn = cached_connections[current_connection_id]) # Invoca Patch to use Fiber
198
196
  conn = connection
199
197
  fresh_connection = true
200
198
  end
@@ -203,15 +201,19 @@ module FiberedMysql2
203
201
  release_connection if fresh_connection
204
202
  end
205
203
 
206
- private
207
-
208
204
  def current_thread
209
205
  Fiber.current
210
206
  end
207
+
208
+ def connection
209
+ cached_connections[current_connection_id] ||= checkout
210
+ end
211
211
  end
212
- if ActiveRecord.gem_version < "7.1"
212
+
213
+ if ::ActiveRecord.gem_version < "7.1"
213
214
  include Adapter_7_0
214
215
  end
216
+ include FiberedMonitorMixin # This is switches the connection pool's mutex and condition variables to event machine / Fiber compatible ones.
215
217
 
216
218
  def initialize(pool_config)
217
219
  if pool_config.db_config.reaping_frequency
@@ -223,46 +225,24 @@ module FiberedMysql2
223
225
  @reaper = nil # no need to keep a reference to this since it does nothing in this sub-class
224
226
  end
225
227
 
226
- def connection
227
- # this is correctly done double-checked locking
228
- # (ThreadSafe::Cache's lookups have volatile semantics)
229
- if (result = cached_connections[current_connection_id])
230
- result
231
- else
232
- synchronize do
233
- if (result = cached_connections[current_connection_id])
234
- result
235
- else
236
- cached_connections[current_connection_id] = checkout
237
- end
238
- end
239
- end
228
+ def current_connection_id
229
+ connection_cache_key(current_thread)
230
+ end
231
+
232
+ def cached_connections
233
+ @thread_cached_conns
240
234
  end
241
235
 
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.
242
238
  def checkout(checkout_timeout = @checkout_timeout)
243
239
  begin
244
- reap_connections
240
+ reap
245
241
  rescue => ex
246
242
  ActiveRecord::Base.logger.error("Exception occurred while executing reap_connections: #{ex}")
247
243
  end
248
244
  super
249
245
  end
250
-
251
- def cached_connections
252
- @thread_cached_conns
253
- end
254
-
255
- def current_connection_id
256
- connection_cache_key(current_thread)
257
- end
258
-
259
- def reap_connections
260
- cached_connections.values.each do |connection|
261
- unless connection.owner.alive?
262
- checkin(connection)
263
- end
264
- end
265
- end
266
246
  end
267
247
  end
268
248
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.3.2.pre.tstarck.7"
4
+ VERSION = "0.4.0.pre.tstarck.1"
5
5
  end
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.2.pre.tstarck.7
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: 2025-08-18 00:00:00.000000000 Z
11
+ date: 2025-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-synchrony
@@ -91,11 +91,11 @@ 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: 1.3.1
96
+ version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.3.27
98
+ rubygems_version: 3.5.22
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: An adapter for fibered mysql2