flydata 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +3 -3
- data/lib/flydata/parser/mysql/dump_parser.rb +36 -18
- data/spec/flydata/parser/mysql/dump_parser_spec.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35ee35146966b2d980eb979c3d36c23ce0c5d36
|
4
|
+
data.tar.gz: 9789cbe06d27163a5afc8cfaf9c44a2bf9de495a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a7fc6bf22d826f3f7444b0ca85724576f517ded96ed56023a1497b2bc2e2e6e6cc1d561a899d01be0d55b7e1de7cba78aec158e7a78a125b588cd07b7e04479
|
7
|
+
data.tar.gz: f2390bf2dd00890e0cb7e2948d5a7930a2266d3d87aecabe0119e20bb7c97ebe3d3cacf6a6f82348495a9374bd3652ce8fa248d17dda19178128ad68b4bf4dc4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.5.
|
5
|
+
# stub: flydata 0.5.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-09-
|
14
|
+
s.date = "2015-09-08"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -161,12 +161,30 @@ EOS
|
|
161
161
|
|
162
162
|
def create_table_locker
|
163
163
|
Fiber.new do
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
# short timeout to avoid blocking other queries
|
165
|
+
client = FlydataMysqlClient.new({reconnect: true, read_timeout:9}.merge(@db_opts))
|
166
|
+
|
167
167
|
q = flush_tables_with_read_lock_query(client)
|
168
168
|
$log.debug "FLUSH TABLES query: #{q}"
|
169
|
-
|
169
|
+
thread_id = nil
|
170
|
+
begin
|
171
|
+
thread_id = client.thread_id
|
172
|
+
client.query(q, retry_count: -1, retry_interval: 1,
|
173
|
+
) do |retry_count, e|
|
174
|
+
# Query failure callback
|
175
|
+
$log.info "Unable to complete FLUSH TABLES WITH READ LOCK. Retrying(#{retry_count}).. error:#{e.to_s}"
|
176
|
+
if retry_count >= 360 # should take an hour to get here
|
177
|
+
raise "Failed to complete FLUSH TABLES WITH READ LOCK after #{retry_count} attemps"
|
178
|
+
end
|
179
|
+
client.query "KILL QUERY #{thread_id}"
|
180
|
+
thread_id = client.thread_id
|
181
|
+
end
|
182
|
+
thread_id = nil
|
183
|
+
ensure
|
184
|
+
if thread_id
|
185
|
+
client.query "KILL QUERY #{thread_id}"
|
186
|
+
end
|
187
|
+
end
|
170
188
|
$log.debug "lock acquired"
|
171
189
|
begin
|
172
190
|
Fiber.yield # Lock is acquired. Wait until it can be unlocked.
|
@@ -223,28 +241,28 @@ EOS
|
|
223
241
|
end
|
224
242
|
end
|
225
243
|
|
226
|
-
# Custom mysql client that
|
227
|
-
#
|
228
|
-
# which can be helpful when handling exceptions
|
244
|
+
# Custom mysql client that gives access to the last query that was
|
245
|
+
# executed using the client which can be helpful when handling exceptions
|
229
246
|
class FlydataMysqlClient < Mysql2::Client
|
230
247
|
|
231
248
|
attr_accessor :last_query
|
232
249
|
|
233
|
-
def initialize(db_opts)
|
234
|
-
#TODO : Pass timeout in as a setting from the data entry
|
235
|
-
super(db_opts.merge(read_timeout: 3600))
|
236
|
-
end
|
237
|
-
|
238
250
|
def query(sql, options = {})
|
239
251
|
@last_query = sql
|
252
|
+
max_retry = options[:retry_count] || 0
|
253
|
+
retry_interval = options[:retry_interval] || 3
|
254
|
+
count = 0
|
255
|
+
result = nil
|
240
256
|
begin
|
241
|
-
super(sql, options)
|
242
|
-
rescue
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
257
|
+
result = super(sql, options)
|
258
|
+
rescue => e
|
259
|
+
count += 1
|
260
|
+
raise e if max_retry != -1 && count > max_retry
|
261
|
+
yield(count, e) if block_given?
|
262
|
+
sleep retry_interval
|
263
|
+
retry
|
247
264
|
end
|
265
|
+
result
|
248
266
|
end
|
249
267
|
end
|
250
268
|
|
@@ -40,8 +40,10 @@ module Flydata
|
|
40
40
|
allow(m).to receive(:query).with(/TABLES/)
|
41
41
|
allow(m).to receive(:query).with("SHOW VARIABLES LIKE 'version'").
|
42
42
|
and_return([{'Value' => '5.1.40-0ubuntu0.12.04.1-log'}])
|
43
|
+
allow(m).to receive(:query).with("FLUSH TABLES WITH READ LOCK;", {retry_count:-1, retry_interval:1})
|
43
44
|
allow(m).to receive(:query).with("SHOW MASTER STATUS;").
|
44
45
|
and_return([{'File' => 'mysql-bin.000451', 'Position' => 89872}])
|
46
|
+
allow(m).to receive(:thread_id).and_return(1191)
|
45
47
|
allow(m).to receive(:close)
|
46
48
|
m
|
47
49
|
end
|
@@ -98,11 +100,11 @@ module Flydata
|
|
98
100
|
raise Mysql2::Error.new("Timeout waiting for a response from the last query. (waited 600 seconds)")
|
99
101
|
end
|
100
102
|
end
|
101
|
-
it 'raises
|
103
|
+
it 'raises a timeout error as is' do
|
102
104
|
described_class.instance_eval { include DummyMysqlClient }
|
103
105
|
sql = "FLUSH LOCAL TABLES"
|
104
106
|
test_client = described_class.new(db_opts)
|
105
|
-
expect{test_client.query(sql)}.to raise_error(
|
107
|
+
expect{test_client.query(sql)}.to raise_error(Mysql2::Error, "Timeout waiting for a response from the last query. (waited 600 seconds)")
|
106
108
|
expect(test_client.last_query).to eq(sql)
|
107
109
|
end
|
108
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-09-
|
15
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|