ar_mysql_flexmaster 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "ar_mysql_flexmaster"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "0.4.1"
15
+ gem.version = "0.4.2"
16
16
 
17
17
  gem.add_runtime_dependency("mysql2")
18
18
  gem.add_runtime_dependency("activerecord")
@@ -105,8 +105,8 @@ module ActiveRecord
105
105
  def retryable_error?(e)
106
106
  case e
107
107
  when Mysql2::Error
108
- # 2006 is gone-away, 61 is can't-connect (for reconnection: true connections)
109
- [2006, 61].include?(e.errno)
108
+ # 2006 is gone-away, 2003 is can't-connect (applicable when reconnect is true)
109
+ [2006, 2003].include?(e.errno)
110
110
  when ActiveRecord::StatementInvalid
111
111
  AR_MESSAGES.any? { |m| e.message.match(m) }
112
112
  end
@@ -134,10 +134,11 @@ module ActiveRecord
134
134
  @connection = cx if cx
135
135
  end
136
136
  end
137
+
137
138
  if @rw == :write && !@connection
138
139
  # desperation mode: we've been asked for the master, but it's just not available.
139
140
  # we'll go ahead and return a connection to the slave, understanding that it'll never work
140
- # for writes.
141
+ # for writes. (we'll call hard_verify and crash)
141
142
  @connection = find_correct_host(:read)
142
143
  end
143
144
  end
@@ -172,14 +173,15 @@ module ActiveRecord
172
173
  clear_collected_errors!
173
174
 
174
175
  sleep_interval = 0.1
175
- tries = @tx_hold_timeout.to_f / sleep_interval
176
+ timeout_at = Time.now.to_f + @tx_hold_timeout
176
177
 
177
- tries.to_i.times do
178
+ begin
178
179
  @connection = find_correct_host(@rw)
179
180
  return if @connection
180
181
 
181
182
  sleep(sleep_interval)
182
- end
183
+ end while Time.now.to_f < timeout_at
184
+
183
185
  raise_no_server_available!
184
186
  end
185
187
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_mysql_flexmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-02 00:00:00.000000000 Z
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mysql2
@@ -175,3 +175,4 @@ test_files:
175
175
  - test/integration/there_and_back_again_test.rb
176
176
  - test/integration/with_queries_to_be_killed_test.rb
177
177
  - test/integration/wrong_setup_test.rb
178
+ has_rdoc: