fibered_mysql2 0.1.0.pre.5 → 0.1.4.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dc370ac1991b20233635be62b5987835aaa7f257d1a5205f7b024265a86580d
4
- data.tar.gz: ca03aa8ba38ed8b7997967c939fd994bf03c4042ddf3fee99c2b15a0fcdb9250
3
+ metadata.gz: 9063356fe2e39d46d7059f916a3e4c319371ce24e6733c6a3e4f557c6089b94c
4
+ data.tar.gz: 768fba3653c38a986833b61bd5fa4ba194dca8e18c7792b978774844589ab7ca
5
5
  SHA512:
6
- metadata.gz: 63e6cabcc9f2e91870802e806017d12140b86d12da87edd4bf4864646207e583aabc76690a4d553ee4b886aae18cc34b5018c1093255ed68d347a9b911b38c96
7
- data.tar.gz: 3fe04ea933864b648c50d804f787577c1742aef9dcb0449c4a3510ba51e483186f7715cb0c949ad0aa8ac70afc3f2078ff91476f01b94bf70388f2e0ae21f303
6
+ metadata.gz: f7f2e77c106191965bebbff721ad7a9d9530195b4eeb970c5ede4f5bfac9fefe91992ddd5e551eb688571db8ed02266f24b8f821db2d25f81369128e0db859ca
7
+ data.tar.gz: c3c9470e559721f63934bbcf9502b662c0ea888f2b0986266db8778ea192609e2564aeca64eaaebf100714dd36504b4e6dac91565036f3732f9f59f0b7054914
data/Appraisals CHANGED
@@ -9,5 +9,5 @@ appraise 'rails-5' do
9
9
  end
10
10
 
11
11
  appraise 'rails-6' do
12
- gem 'rails', '~> 6.0'
12
+ gem 'rails', '~> 6.0.0'
13
13
  end
data/CHANGELOG.md CHANGED
@@ -4,11 +4,36 @@ 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.1.0] - Unreleased
7
+ ## [0.1.4] - Unreleased
8
+ ### Fixed
9
+ - Disable the ConnectionPool::Reaper in Rails 5 and 6 as it was in 4. This is important since it is
10
+ threaded, not fibered.
11
+
12
+ ## [0.1.3] - 2021-06-17
13
+ ### Fixed
14
+ - When checking that @owner is a Fiber, allow nil.
15
+
16
+ ## [0.1.2] - 2021-06-16
17
+ ### Fixed
18
+ - Added checking to be certain that @owner is never overwritten with a non-Fiber by another mixin.
19
+
20
+ ## [0.1.1] - 2021-02-12
21
+ ### Fixed
22
+ - Fixed bug with Rails 5+ adapter where connections that have `steal!` called on them were not having their owner updated to the current Fiber, which would then cause an exception when trying to expire the connection (this showed up with the Rails 5 `ConnectionPool::Reaper` that reaps unused connections)
23
+
24
+ ### Changed
25
+ - Updated Rails 6 dependency to 6.0.x for now as 6.1+ requires a newer version of the mysql gem (0.5+) that we do not yet support
26
+
27
+
28
+ ## [0.1.0] - 2020-10-23
8
29
  ### Added
9
30
  - Added an adapter for Rails 4, 5, and 6.
10
31
  - Added appraisals for Rails 4, 5, and 6.
11
32
  - Added TravisCI unit test pipeline.
12
33
  - Added coverage reports via Coveralls.
13
34
 
35
+ [0.1.4]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.3..v0.1.4
36
+ [0.1.3]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.2..v0.1.3
37
+ [0.1.2]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.1..v0.1.2
38
+ [0.1.1]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.0..v0.1.1
14
39
  [0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
data/Gemfile CHANGED
@@ -8,8 +8,10 @@ gemspec
8
8
  gem 'appraisal'
9
9
  gem 'bundler', '~> 1.8'
10
10
  gem 'coveralls', require: false
11
+ gem 'mimemagic', '~> 0.3', git: 'git@github.com:Invoca/mimemagic', ref: 'b084ce8d50c080f5a312156498be21a541fe72a2'
11
12
  gem 'mysql2', '0.4.5'
12
13
  gem 'pry', '~> 0.13'
13
14
  gem 'pry-byebug', '~> 3.9'
15
+ gem 'rails', '< 6.1'
14
16
  gem 'rake', '~> 10.0'
15
17
  gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,14 @@
1
+ GIT
2
+ remote: git@github.com:Invoca/mimemagic
3
+ revision: b084ce8d50c080f5a312156498be21a541fe72a2
4
+ ref: b084ce8d50c080f5a312156498be21a541fe72a2
5
+ specs:
6
+ mimemagic (0.3.5)
7
+
1
8
  PATH
2
9
  remote: .
3
10
  specs:
4
- fibered_mysql2 (0.1.0.pre.5)
11
+ fibered_mysql2 (0.1.4.pre.1)
5
12
  em-synchrony (~> 1.0)
6
13
  rails (>= 4.2, < 7)
7
14
 
@@ -63,14 +70,14 @@ GEM
63
70
  minitest (~> 5.1)
64
71
  tzinfo (~> 1.1)
65
72
  zeitwerk (~> 2.2, >= 2.2.2)
66
- appraisal (2.3.0)
73
+ appraisal (2.4.0)
67
74
  bundler
68
75
  rake
69
76
  thor (>= 0.14.0)
70
77
  builder (3.2.4)
71
78
  byebug (11.1.3)
72
79
  coderay (1.1.3)
73
- concurrent-ruby (1.1.7)
80
+ concurrent-ruby (1.1.8)
74
81
  coveralls (0.8.23)
75
82
  json (>= 1.8, < 3)
76
83
  simplecov (~> 0.16.1)
@@ -82,14 +89,14 @@ GEM
82
89
  docile (1.3.2)
83
90
  em-synchrony (1.0.6)
84
91
  eventmachine (>= 1.0.0.beta.1)
85
- erubi (1.9.0)
92
+ erubi (1.10.0)
86
93
  eventmachine (1.2.7)
87
94
  globalid (0.4.2)
88
95
  activesupport (>= 4.2.0)
89
- i18n (1.8.5)
96
+ i18n (1.8.7)
90
97
  concurrent-ruby (~> 1.0)
91
98
  json (2.3.1)
92
- loofah (2.7.0)
99
+ loofah (2.8.0)
93
100
  crass (~> 1.0.2)
94
101
  nokogiri (>= 1.5.9)
95
102
  mail (2.7.1)
@@ -97,10 +104,9 @@ GEM
97
104
  marcel (0.3.3)
98
105
  mimemagic (~> 0.3.2)
99
106
  method_source (1.0.0)
100
- mimemagic (0.3.5)
101
107
  mini_mime (1.0.2)
102
108
  mini_portile2 (2.4.0)
103
- minitest (5.14.2)
109
+ minitest (5.14.3)
104
110
  mysql2 (0.4.5)
105
111
  nio4r (2.5.4)
106
112
  nokogiri (1.10.10)
@@ -173,12 +179,12 @@ GEM
173
179
  thread_safe (0.3.6)
174
180
  tins (1.25.0)
175
181
  sync
176
- tzinfo (1.2.7)
182
+ tzinfo (1.2.9)
177
183
  thread_safe (~> 0.1)
178
184
  websocket-driver (0.7.3)
179
185
  websocket-extensions (>= 0.1.0)
180
186
  websocket-extensions (0.1.5)
181
- zeitwerk (2.4.0)
187
+ zeitwerk (2.4.1)
182
188
 
183
189
  PLATFORMS
184
190
  ruby
@@ -188,11 +194,13 @@ DEPENDENCIES
188
194
  bundler (~> 1.8)
189
195
  coveralls
190
196
  fibered_mysql2!
197
+ mimemagic (~> 0.3)!
191
198
  mysql2 (= 0.4.5)
192
199
  pry (~> 0.13)
193
200
  pry-byebug (~> 3.9)
201
+ rails (< 6.1)
194
202
  rake (~> 10.0)
195
203
  rspec (~> 3.0)
196
204
 
197
205
  BUNDLED WITH
198
- 1.17.2
206
+ 1.17.3
@@ -10,6 +10,6 @@ gem "pry", "~> 0.13"
10
10
  gem "pry-byebug", "~> 3.9"
11
11
  gem "rake", "~> 10.0"
12
12
  gem "rspec", "~> 3.0"
13
- gem "rails", "~> 6.0"
13
+ gem "rails", "~> 6.0.0"
14
14
 
15
15
  gemspec path: "../"
@@ -20,10 +20,10 @@ module FiberedMysql2
20
20
  def lease
21
21
  if in_use?
22
22
  msg = "Cannot lease connection, ".dup
23
- if @owner == Fiber.current
23
+ if owner_fiber == Fiber.current
24
24
  msg << "it is already leased by the current fiber."
25
25
  else
26
- msg << "it is already in use by a different fiber: #{@owner}. " \
26
+ msg << "it is already in use by a different fiber: #{owner_fiber}. " \
27
27
  "Current fiber: #{Fiber.current}."
28
28
  end
29
29
  raise ::ActiveRecord::ActiveRecordError, msg
@@ -37,9 +37,9 @@ module FiberedMysql2
37
37
  # Because we are actively releasing connections from dead fibers, we only want
38
38
  # to enforce that we're expiring the current fibers connection, iff the owner
39
39
  # of the connection is still alive.
40
- if @owner.alive? && @owner != Fiber.current
40
+ if owner_fiber.alive? && owner_fiber != Fiber.current
41
41
  raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
42
- "it is owned by a different fiber: #{@owner}. " \
42
+ "it is owned by a different fiber: #{owner_fiber}. " \
43
43
  "Current fiber: #{Fiber.current}."
44
44
  end
45
45
 
@@ -49,6 +49,26 @@ module FiberedMysql2
49
49
  raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, it is not currently leased."
50
50
  end
51
51
  end
52
+
53
+ def steal!
54
+ if in_use?
55
+ if owner_fiber != Fiber.current
56
+ pool.send :remove_connection_from_thread_cache, self, owner_fiber
57
+
58
+ @owner = Fiber.current
59
+ end
60
+ else
61
+ raise ::ActiveRecord::ActiveRecordError, "Cannot steal connection, it is not currently leased."
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ def owner_fiber
68
+ @owner.nil? || @owner.is_a?(Fiber) or
69
+ raise "@owner must be a Fiber! Found #{@owner.inspect}"
70
+ @owner
71
+ end
52
72
  end
53
73
 
54
74
  class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::EMMysql2Adapter
@@ -173,6 +173,7 @@ module FiberedMysql2
173
173
 
174
174
  def initialize(connection_spec, *args, **keyword_args)
175
175
  connection_spec.config[:reaping_frequency] and raise "reaping_frequency is not supported (the ActiveRecord Reaper is thread-based)"
176
+ connection_spec.config[:reaping_frequency] = nil # starting in Rails 5, this defaults to 60 if not explicitly set
176
177
 
177
178
  super(connection_spec, *args, **keyword_args)
178
179
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FiberedMysql2
4
- VERSION = "0.1.0.pre.5"
4
+ VERSION = "0.1.4.pre.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.1.0.pre.5
4
+ version: 0.1.4.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-synchrony
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '7'
47
- description:
47
+ description:
48
48
  email:
49
49
  - development@invoca.com
50
50
  executables: []
@@ -77,7 +77,7 @@ licenses: []
77
77
  metadata:
78
78
  allowed_push_host: https://rubygems.org
79
79
  homepage_uri: https://github.com/Invoca/fibered_mysql2
80
- post_install_message:
80
+ post_install_message:
81
81
  rdoc_options: []
82
82
  require_paths:
83
83
  - lib
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: 1.3.1
94
94
  requirements: []
95
95
  rubygems_version: 3.0.1
96
- signing_key:
96
+ signing_key:
97
97
  specification_version: 4
98
98
  summary: An adapter for fibered mysql2
99
99
  test_files: []