lhm-shopify 3.5.1 → 3.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +1 -1
- data/README.md +14 -3
- data/Rakefile +6 -6
- data/dev.yml +5 -2
- data/gemfiles/activerecord_5.2.gemfile.lock +1 -1
- data/gemfiles/activerecord_6.0.gemfile.lock +1 -1
- data/gemfiles/activerecord_6.1.gemfile.lock +1 -1
- data/gemfiles/activerecord_7.0.0.alpha2.gemfile.lock +1 -1
- data/lib/lhm/atomic_switcher.rb +4 -3
- data/lib/lhm/chunk_insert.rb +6 -3
- data/lib/lhm/chunker.rb +6 -6
- data/lib/lhm/cleanup/current.rb +4 -1
- data/lib/lhm/connection.rb +33 -25
- data/lib/lhm/entangler.rb +5 -4
- data/lib/lhm/invoker.rb +5 -3
- data/lib/lhm/locked_switcher.rb +2 -0
- data/lib/lhm/proxysql_helper.rb +1 -1
- data/lib/lhm/sql_retry.rb +56 -60
- data/lib/lhm/version.rb +1 -1
- data/lib/lhm.rb +30 -24
- data/spec/integration/atomic_switcher_spec.rb +28 -17
- data/spec/integration/chunker_spec.rb +7 -5
- data/spec/integration/integration_helper.rb +4 -6
- data/spec/integration/lhm_spec.rb +3 -4
- data/spec/integration/proxysql_spec.rb +1 -1
- data/spec/integration/sql_retry/lock_wait_spec.rb +2 -2
- data/spec/integration/sql_retry/retry_with_proxysql_spec.rb +8 -7
- data/spec/test_helper.rb +3 -0
- data/spec/unit/chunker_spec.rb +44 -43
- data/spec/unit/connection_spec.rb +37 -12
- data/spec/unit/entangler_spec.rb +31 -9
- data/spec/unit/lhm_spec.rb +17 -0
- data/spec/unit/throttler/slave_lag_spec.rb +1 -1
- metadata +2 -2
data/spec/unit/chunker_spec.rb
CHANGED
@@ -12,7 +12,8 @@ require 'lhm/connection'
|
|
12
12
|
describe Lhm::Chunker do
|
13
13
|
include UnitHelper
|
14
14
|
|
15
|
-
|
15
|
+
EXPECTED_RETRY_FLAGS_CHUNKER = {:should_retry => true, :log_prefix => "Chunker"}
|
16
|
+
EXPECTED_RETRY_FLAGS_CHUNK_INSERT = {:should_retry => true, :log_prefix => "ChunkInsert"}
|
16
17
|
|
17
18
|
before(:each) do
|
18
19
|
@origin = Lhm::Table.new('foo')
|
@@ -41,11 +42,11 @@ describe Lhm::Chunker do
|
|
41
42
|
5
|
42
43
|
end
|
43
44
|
|
44
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 4/),
|
45
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 8 order by id limit 1 offset 4/),
|
46
|
-
@connection.expects(:update).with(regexp_matches(/between 1 and 7/),
|
47
|
-
@connection.expects(:update).with(regexp_matches(/between 8 and 10/),
|
48
|
-
@connection.expects(:execute).twice.with(regexp_matches(/show warnings/),
|
45
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 4/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(7)
|
46
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 8 order by id limit 1 offset 4/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(21)
|
47
|
+
@connection.expects(:update).with(regexp_matches(/between 1 and 7/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
48
|
+
@connection.expects(:update).with(regexp_matches(/between 8 and 10/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
49
|
+
@connection.expects(:execute).twice.with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
|
49
50
|
|
50
51
|
@chunker.run
|
51
52
|
end
|
@@ -56,17 +57,17 @@ describe Lhm::Chunker do
|
|
56
57
|
2
|
57
58
|
end
|
58
59
|
|
59
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),
|
60
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 3 order by id limit 1 offset 1/),
|
61
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 5 order by id limit 1 offset 1/),
|
62
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 7 order by id limit 1 offset 1/),
|
63
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 9 order by id limit 1 offset 1/),
|
60
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(2)
|
61
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 3 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(4)
|
62
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 5 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(6)
|
63
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 7 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(8)
|
64
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 9 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(10)
|
64
65
|
|
65
|
-
@connection.expects(:update).with(regexp_matches(/between 1 and 2/),
|
66
|
-
@connection.expects(:update).with(regexp_matches(/between 3 and 4/),
|
67
|
-
@connection.expects(:update).with(regexp_matches(/between 5 and 6/),
|
68
|
-
@connection.expects(:update).with(regexp_matches(/between 7 and 8/),
|
69
|
-
@connection.expects(:update).with(regexp_matches(/between 9 and 10/),
|
66
|
+
@connection.expects(:update).with(regexp_matches(/between 1 and 2/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
67
|
+
@connection.expects(:update).with(regexp_matches(/between 3 and 4/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
68
|
+
@connection.expects(:update).with(regexp_matches(/between 5 and 6/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
69
|
+
@connection.expects(:update).with(regexp_matches(/between 7 and 8/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
70
|
+
@connection.expects(:update).with(regexp_matches(/between 9 and 10/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
70
71
|
|
71
72
|
@chunker.run
|
72
73
|
end
|
@@ -83,17 +84,17 @@ describe Lhm::Chunker do
|
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
86
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),
|
87
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 3 order by id limit 1 offset 2/),
|
88
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 6 order by id limit 1 offset 2/),
|
89
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 9 order by id limit 1 offset 2/),
|
87
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(2)
|
88
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 3 order by id limit 1 offset 2/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(5)
|
89
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 6 order by id limit 1 offset 2/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(8)
|
90
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 9 order by id limit 1 offset 2/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(nil)
|
90
91
|
|
91
|
-
@connection.expects(:update).with(regexp_matches(/between 1 and 2/),
|
92
|
-
@connection.expects(:update).with(regexp_matches(/between 3 and 5/),
|
93
|
-
@connection.expects(:update).with(regexp_matches(/between 6 and 8/),
|
94
|
-
@connection.expects(:update).with(regexp_matches(/between 9 and 10/),
|
92
|
+
@connection.expects(:update).with(regexp_matches(/between 1 and 2/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
93
|
+
@connection.expects(:update).with(regexp_matches(/between 3 and 5/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
94
|
+
@connection.expects(:update).with(regexp_matches(/between 6 and 8/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
95
|
+
@connection.expects(:update).with(regexp_matches(/between 9 and 10/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
95
96
|
|
96
|
-
@connection.expects(:execute).twice.with(regexp_matches(/show warnings/),
|
97
|
+
@connection.expects(:execute).twice.with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
|
97
98
|
|
98
99
|
@chunker.run
|
99
100
|
end
|
@@ -103,8 +104,8 @@ describe Lhm::Chunker do
|
|
103
104
|
:start => 1,
|
104
105
|
:limit => 1)
|
105
106
|
|
106
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 0/),
|
107
|
-
@connection.expects(:update).with(regexp_matches(/between 1 and 1/),
|
107
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 0/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(nil)
|
108
|
+
@connection.expects(:update).with(regexp_matches(/between 1 and 1/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
|
108
109
|
|
109
110
|
@chunker.run
|
110
111
|
end
|
@@ -117,17 +118,17 @@ describe Lhm::Chunker do
|
|
117
118
|
2
|
118
119
|
end
|
119
120
|
|
120
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 2 order by id limit 1 offset 1/),
|
121
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 4 order by id limit 1 offset 1/),
|
122
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 6 order by id limit 1 offset 1/),
|
123
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 8 order by id limit 1 offset 1/),
|
124
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 10 order by id limit 1 offset 1/),
|
121
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 2 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(3)
|
122
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 4 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(5)
|
123
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 6 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(7)
|
124
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 8 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(9)
|
125
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 10 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(nil)
|
125
126
|
|
126
|
-
@connection.expects(:update).with(regexp_matches(/between 2 and 3/),
|
127
|
-
@connection.expects(:update).with(regexp_matches(/between 4 and 5/),
|
128
|
-
@connection.expects(:update).with(regexp_matches(/between 6 and 7/),
|
129
|
-
@connection.expects(:update).with(regexp_matches(/between 8 and 9/),
|
130
|
-
@connection.expects(:update).with(regexp_matches(/between 10 and 10/),
|
127
|
+
@connection.expects(:update).with(regexp_matches(/between 2 and 3/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
128
|
+
@connection.expects(:update).with(regexp_matches(/between 4 and 5/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
129
|
+
@connection.expects(:update).with(regexp_matches(/between 6 and 7/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
130
|
+
@connection.expects(:update).with(regexp_matches(/between 8 and 9/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
|
131
|
+
@connection.expects(:update).with(regexp_matches(/between 10 and 10/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
|
131
132
|
|
132
133
|
@chunker.run
|
133
134
|
end
|
@@ -141,9 +142,9 @@ describe Lhm::Chunker do
|
|
141
142
|
2
|
142
143
|
end
|
143
144
|
|
144
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),
|
145
|
-
@connection.expects(:update).with(regexp_matches(/where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`/),
|
146
|
-
@connection.expects(:execute).with(regexp_matches(/show warnings/),
|
145
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(2)
|
146
|
+
@connection.expects(:update).with(regexp_matches(/where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
|
147
|
+
@connection.expects(:execute).with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
|
147
148
|
|
148
149
|
def @migration.conditions
|
149
150
|
"where foo.created_at > '2013-07-10' or foo.baz = 'quux'"
|
@@ -161,9 +162,9 @@ describe Lhm::Chunker do
|
|
161
162
|
2
|
162
163
|
end
|
163
164
|
|
164
|
-
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),
|
165
|
-
@connection.expects(:update).with(regexp_matches(/inner join bar on foo.id = bar.foo_id and/),
|
166
|
-
@connection.expects(:execute).with(regexp_matches(/show warnings/),
|
165
|
+
@connection.expects(:select_value).with(regexp_matches(/where id >= 1 order by id limit 1 offset 1/),EXPECTED_RETRY_FLAGS_CHUNKER).returns(2)
|
166
|
+
@connection.expects(:update).with(regexp_matches(/inner join bar on foo.id = bar.foo_id and/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
|
167
|
+
@connection.expects(:execute).with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
|
167
168
|
|
168
169
|
def @migration.conditions
|
169
170
|
'inner join bar on foo.id = bar.foo_id'
|
@@ -15,9 +15,13 @@ describe Lhm::Connection do
|
|
15
15
|
ar_connection.stubs(:execute).raises(LOCK_WAIT).then.returns(true)
|
16
16
|
ar_connection.stubs(:active?).returns(true)
|
17
17
|
|
18
|
-
connection = Lhm::Connection.new(connection: ar_connection
|
18
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
19
|
+
retriable: {
|
20
|
+
base_interval: 0
|
21
|
+
}
|
22
|
+
})
|
19
23
|
|
20
|
-
connection.execute("SHOW TABLES", should_retry: true
|
24
|
+
connection.execute("SHOW TABLES", should_retry: true)
|
21
25
|
|
22
26
|
log_messages = @logs.string.split("\n")
|
23
27
|
assert_equal(1, log_messages.length)
|
@@ -31,9 +35,14 @@ describe Lhm::Connection do
|
|
31
35
|
.then.returns(true)
|
32
36
|
ar_connection.stubs(:active?).returns(true)
|
33
37
|
|
34
|
-
connection = Lhm::Connection.new(connection: ar_connection
|
38
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
39
|
+
retriable: {
|
40
|
+
base_interval: 0,
|
41
|
+
tries: 3
|
42
|
+
}
|
43
|
+
})
|
35
44
|
|
36
|
-
connection.execute("SHOW TABLES", should_retry: true
|
45
|
+
connection.execute("SHOW TABLES", should_retry: true)
|
37
46
|
|
38
47
|
log_messages = @logs.string.split("\n")
|
39
48
|
assert_equal(2, log_messages.length)
|
@@ -46,9 +55,14 @@ describe Lhm::Connection do
|
|
46
55
|
.then.returns(1)
|
47
56
|
ar_connection.stubs(:active?).returns(true)
|
48
57
|
|
49
|
-
connection = Lhm::Connection.new(connection: ar_connection
|
58
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
59
|
+
retriable: {
|
60
|
+
base_interval: 0,
|
61
|
+
tries: 3
|
62
|
+
}
|
63
|
+
})
|
50
64
|
|
51
|
-
val = connection.update("SHOW TABLES", should_retry: true
|
65
|
+
val = connection.update("SHOW TABLES", should_retry: true)
|
52
66
|
|
53
67
|
log_messages = @logs.string.split("\n")
|
54
68
|
assert_equal val, 1
|
@@ -62,24 +76,35 @@ describe Lhm::Connection do
|
|
62
76
|
.then.returns("dummy")
|
63
77
|
ar_connection.stubs(:active?).returns(true)
|
64
78
|
|
65
|
-
connection = Lhm::Connection.new(connection: ar_connection
|
79
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
80
|
+
retriable: {
|
81
|
+
base_interval: 0,
|
82
|
+
tries: 3
|
83
|
+
}
|
84
|
+
})
|
66
85
|
|
67
|
-
val = connection.select_value("SHOW TABLES", should_retry: true
|
86
|
+
val = connection.select_value("SHOW TABLES", should_retry: true)
|
68
87
|
|
69
88
|
log_messages = @logs.string.split("\n")
|
70
89
|
assert_equal val, "dummy"
|
71
90
|
assert_equal(2, log_messages.length)
|
72
91
|
end
|
73
92
|
|
74
|
-
it "Queries should be tagged with ProxySQL tag if
|
93
|
+
it "Queries should be tagged with ProxySQL tag if reconnect_with_consistent_host is enabled" do
|
75
94
|
ar_connection = mock()
|
76
|
-
ar_connection.expects(:public_send).with(:select_value, "#{Lhm::ProxySQLHelper::ANNOTATION}
|
95
|
+
ar_connection.expects(:public_send).with(:select_value, "SHOW TABLES #{Lhm::ProxySQLHelper::ANNOTATION}").returns("dummy")
|
77
96
|
ar_connection.stubs(:execute).times(4).returns([["dummy"]])
|
78
97
|
ar_connection.stubs(:active?).returns(true)
|
79
98
|
|
80
|
-
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
99
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
100
|
+
reconnect_with_consistent_host: true,
|
101
|
+
retriable: {
|
102
|
+
base_interval: 0,
|
103
|
+
tries: 3
|
104
|
+
}
|
105
|
+
})
|
81
106
|
|
82
|
-
val = connection.select_value("SHOW TABLES", should_retry: true
|
107
|
+
val = connection.select_value("SHOW TABLES", should_retry: true)
|
83
108
|
|
84
109
|
assert_equal val, "dummy"
|
85
110
|
end
|
data/spec/unit/entangler_spec.rb
CHANGED
@@ -69,9 +69,15 @@ describe Lhm::Entangler do
|
|
69
69
|
.raises(Mysql2::Error, 'Lock wait timeout exceeded; try restarting transaction')
|
70
70
|
ar_connection.stubs(:active?).returns(true)
|
71
71
|
|
72
|
-
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
72
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
73
|
+
reconnect_with_consistent_host: true,
|
74
|
+
retriable: {
|
75
|
+
base_interval: 0,
|
76
|
+
tries: tries
|
77
|
+
}
|
78
|
+
})
|
73
79
|
|
74
|
-
@entangler = Lhm::Entangler.new(@migration, connection
|
80
|
+
@entangler = Lhm::Entangler.new(@migration, connection)
|
75
81
|
|
76
82
|
assert_raises(Mysql2::Error) { @entangler.before }
|
77
83
|
end
|
@@ -83,9 +89,14 @@ describe Lhm::Entangler do
|
|
83
89
|
.then
|
84
90
|
.raises(Mysql2::Error, 'The MySQL server is running with the --read-only option so it cannot execute this statement.')
|
85
91
|
ar_connection.stubs(:active?).returns(true)
|
86
|
-
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
87
|
-
|
88
|
-
|
92
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
93
|
+
reconnect_with_consistent_host: true,
|
94
|
+
retriable: {
|
95
|
+
base_interval: 0
|
96
|
+
},
|
97
|
+
})
|
98
|
+
|
99
|
+
@entangler = Lhm::Entangler.new(@migration, connection)
|
89
100
|
assert_raises(Mysql2::Error) { @entangler.before }
|
90
101
|
end
|
91
102
|
|
@@ -99,9 +110,14 @@ describe Lhm::Entangler do
|
|
99
110
|
.returns([["dummy"]])
|
100
111
|
ar_connection.stubs(:active?).returns(true)
|
101
112
|
|
102
|
-
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
113
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
114
|
+
reconnect_with_consistent_host: true,
|
115
|
+
retriable: {
|
116
|
+
base_interval: 0
|
117
|
+
},
|
118
|
+
})
|
103
119
|
|
104
|
-
@entangler = Lhm::Entangler.new(@migration, connection
|
120
|
+
@entangler = Lhm::Entangler.new(@migration, connection)
|
105
121
|
|
106
122
|
assert @entangler.before
|
107
123
|
end
|
@@ -126,9 +142,15 @@ describe Lhm::Entangler do
|
|
126
142
|
.raises(Mysql2::Error, 'Lock wait timeout exceeded; try restarting transaction') # final error
|
127
143
|
ar_connection.stubs(:active?).returns(true)
|
128
144
|
|
129
|
-
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
145
|
+
connection = Lhm::Connection.new(connection: ar_connection, options: {
|
146
|
+
reconnect_with_consistent_host: true,
|
147
|
+
retriable: {
|
148
|
+
tries: 5,
|
149
|
+
base_interval: 0
|
150
|
+
},
|
151
|
+
})
|
130
152
|
|
131
|
-
@entangler = Lhm::Entangler.new(@migration, connection
|
153
|
+
@entangler = Lhm::Entangler.new(@migration, connection)
|
132
154
|
|
133
155
|
assert_raises(Mysql2::Error) { @entangler.before }
|
134
156
|
end
|
data/spec/unit/lhm_spec.rb
CHANGED
@@ -26,4 +26,21 @@ describe Lhm do
|
|
26
26
|
value(Lhm.logger.instance_eval { @logdev }.dev.path).must_equal 'omg.ponies'
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
describe 'api' do
|
31
|
+
|
32
|
+
before(:each) do
|
33
|
+
@connection = mock()
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should create a new connection when calling setup' do
|
37
|
+
Lhm.setup(@connection)
|
38
|
+
value(Lhm.connection).must_be_kind_of(Lhm::Connection)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should create a new connection when none is created' do
|
42
|
+
ActiveRecord::Base.stubs(:connection).returns(@connection)
|
43
|
+
value(Lhm.connection).must_be_kind_of(Lhm::Connection)
|
44
|
+
end
|
45
|
+
end
|
29
46
|
end
|
@@ -142,7 +142,7 @@ describe Lhm::Throttler::Slave do
|
|
142
142
|
Lhm::Throttler::Slave.any_instance.stubs(:config).returns([])
|
143
143
|
|
144
144
|
slave = Lhm::Throttler::Slave.new('slave', @dummy_mysql_client_config)
|
145
|
-
|
145
|
+
Logger.any_instance.expects(:info).with("Unable to connect and/or query slave: Can't connect to MySQL server")
|
146
146
|
assert_equal(0, slave.lag)
|
147
147
|
end
|
148
148
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhm-shopify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SoundCloud
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: retriable
|