lhm-shopify 4.4.0 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/gemfiles/activerecord_6.1.gemfile.lock +1 -1
- data/gemfiles/activerecord_7.0.gemfile.lock +1 -1
- data/gemfiles/activerecord_7.1.gemfile.lock +1 -1
- data/gemfiles/activerecord_head.gemfile.lock +1 -1
- data/lib/lhm/chunker.rb +2 -6
- data/lib/lhm/throttler/backoff_reduction.rb +42 -0
- data/lib/lhm/throttler/replica_lag.rb +3 -0
- data/lib/lhm/throttler/threads_running.rb +3 -0
- data/lib/lhm/throttler/time.rb +2 -30
- data/lib/lhm/throttler.rb +1 -0
- data/lib/lhm/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ef875eccb1a986bb82ef5ee9d981e229ca54fc92e58f61b6e48768928e48baf
|
4
|
+
data.tar.gz: d206155bcf16a94c2dc78622826c35b57f7e09b4d9fff1ddad9726d1a48d61fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3c37c8387638aebcdcb3caced88a39b998247a55a130fc8eade81b4c37622af8acdb570e234ce1c3fa25562ec460844e9cc48e9d9d5d1fe4284c9a6d7f4be8
|
7
|
+
data.tar.gz: d5a1b197b4260aa494a30de528cdf6e5cfa6e8b81c9f40b40eb9e71fcdcae1c73db6f955d599d5930d581b7c1be7623dc0f96e0112073aa063f178157b1b52c6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/lhm/chunker.rb
CHANGED
@@ -37,10 +37,6 @@ module Lhm
|
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
40
|
-
def handle_max_binlog_exceeded_error
|
41
|
-
@throttler.backoff_stride
|
42
|
-
end
|
43
|
-
|
44
40
|
def execute
|
45
41
|
@start_time = Time.now
|
46
42
|
|
@@ -54,9 +50,9 @@ module Lhm
|
|
54
50
|
begin
|
55
51
|
affected_rows = ChunkInsert.new(@migration, @connection, bottom, top, @retry_options).insert_and_return_count_of_rows_created
|
56
52
|
rescue ActiveRecord::StatementInvalid => e
|
57
|
-
if e.message.downcase.include?("transaction required more than 'max_binlog_cache_size' bytes of storage")
|
53
|
+
if e.message.downcase.include?("transaction required more than 'max_binlog_cache_size' bytes of storage") && @throttler.respond_to?(:backoff_stride)
|
58
54
|
Lhm.logger.info("Encountered max_binlog_cache_size error, attempting to reduce stride size")
|
59
|
-
|
55
|
+
@throttler.backoff_stride
|
60
56
|
next
|
61
57
|
else
|
62
58
|
raise e
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Lhm
|
2
|
+
module Throttler
|
3
|
+
module BackoffReduction
|
4
|
+
DEFAULT_BACKOFF_REDUCTION_FACTOR = 0.2
|
5
|
+
MIN_STRIDE_SIZE = 1
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@backoff_reduction_factor = options[:backoff_reduction_factor] || DEFAULT_BACKOFF_REDUCTION_FACTOR
|
9
|
+
@min_stride_size = options[:min_stride_size] || MIN_STRIDE_SIZE
|
10
|
+
|
11
|
+
if @backoff_reduction_factor >= 1 || @backoff_reduction_factor <= 0
|
12
|
+
raise ArgumentError, 'backoff_reduction_factor must be between greater than 0, and less than 1'
|
13
|
+
end
|
14
|
+
|
15
|
+
if @min_stride_size < 1
|
16
|
+
raise ArgumentError, 'min_stride_size must be an integer greater than 0'
|
17
|
+
end
|
18
|
+
|
19
|
+
if !@min_stride_size.is_a?(Integer)
|
20
|
+
raise ArgumentError, 'min_stride_size must be an integer'
|
21
|
+
end
|
22
|
+
|
23
|
+
if @min_stride_size > @stride
|
24
|
+
raise ArgumentError, 'min_stride_size must be less than or equal to stride'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def backoff_stride
|
29
|
+
new_stride = (@stride * (1 - @backoff_reduction_factor)).to_i
|
30
|
+
|
31
|
+
if new_stride == @stride
|
32
|
+
raise RuntimeError, "Cannot backoff any further"
|
33
|
+
end
|
34
|
+
|
35
|
+
if new_stride < @min_stride_size
|
36
|
+
raise RuntimeError, "Cannot reduce stride below #{@min_stride_size}"
|
37
|
+
end
|
38
|
+
@stride = new_stride
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -13,6 +13,7 @@ module Lhm
|
|
13
13
|
|
14
14
|
class ReplicaLag
|
15
15
|
include Command
|
16
|
+
include BackoffReduction
|
16
17
|
|
17
18
|
INITIAL_TIMEOUT = 0.1
|
18
19
|
DEFAULT_STRIDE = 2_000
|
@@ -29,6 +30,8 @@ module Lhm
|
|
29
30
|
@replicas = {}
|
30
31
|
@get_config = options[:current_config]
|
31
32
|
@check_only = options[:check_only]
|
33
|
+
|
34
|
+
super
|
32
35
|
end
|
33
36
|
|
34
37
|
def execute
|
@@ -2,6 +2,7 @@ module Lhm
|
|
2
2
|
module Throttler
|
3
3
|
class ThreadsRunning
|
4
4
|
include Command
|
5
|
+
include BackoffReduction
|
5
6
|
|
6
7
|
DEFAULT_STRIDE = 2_000
|
7
8
|
DEFAULT_INITIAL_TIMEOUT = 0.1
|
@@ -17,6 +18,8 @@ module Lhm
|
|
17
18
|
@timeout_seconds = @initial_timeout_seconds
|
18
19
|
@healthy_range = options[:healthy_range] || DEFAULT_HEALTHY_RANGE
|
19
20
|
@connection = options[:connection]
|
21
|
+
|
22
|
+
super
|
20
23
|
end
|
21
24
|
|
22
25
|
def threads_running
|
data/lib/lhm/throttler/time.rb
CHANGED
@@ -2,6 +2,7 @@ module Lhm
|
|
2
2
|
module Throttler
|
3
3
|
class Time
|
4
4
|
include Command
|
5
|
+
include BackoffReduction
|
5
6
|
|
6
7
|
DEFAULT_TIMEOUT = 0.1
|
7
8
|
DEFAULT_STRIDE = 2_000
|
@@ -14,37 +15,8 @@ module Lhm
|
|
14
15
|
def initialize(options = {})
|
15
16
|
@timeout_seconds = options[:delay] || DEFAULT_TIMEOUT
|
16
17
|
@stride = options[:stride] || DEFAULT_STRIDE
|
17
|
-
@backoff_reduction_factor = options[:backoff_reduction_factor] || DEFAULT_BACKOFF_REDUCTION_FACTOR
|
18
|
-
@min_stride_size = options[:min_stride_size] || MIN_STRIDE_SIZE
|
19
18
|
|
20
|
-
|
21
|
-
raise ArgumentError, 'backoff_reduction_factor must be between greater than 0, and less than 1'
|
22
|
-
end
|
23
|
-
|
24
|
-
if @min_stride_size < 1
|
25
|
-
raise ArgumentError, 'min_stride_size must be an integer greater than 0'
|
26
|
-
end
|
27
|
-
|
28
|
-
if !@min_stride_size.is_a?(Integer)
|
29
|
-
raise ArgumentError, 'min_stride_size must be an integer'
|
30
|
-
end
|
31
|
-
|
32
|
-
if @min_stride_size > @stride
|
33
|
-
raise ArgumentError, 'min_stride_size must be less than or equal to stride'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def backoff_stride
|
38
|
-
new_stride = (@stride * (1 - @backoff_reduction_factor)).to_i
|
39
|
-
|
40
|
-
if new_stride == @stride
|
41
|
-
raise RuntimeError, "Cannot backoff any further"
|
42
|
-
end
|
43
|
-
|
44
|
-
if new_stride < @min_stride_size
|
45
|
-
raise RuntimeError, "Cannot reduce stride below #{@min_stride_size}"
|
46
|
-
end
|
47
|
-
@stride = new_stride
|
19
|
+
super
|
48
20
|
end
|
49
21
|
|
50
22
|
def execute
|
data/lib/lhm/throttler.rb
CHANGED
data/lib/lhm/version.rb
CHANGED
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: 4.4.
|
4
|
+
version: 4.4.1
|
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: 2024-08-
|
15
|
+
date: 2024-08-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: retriable
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- lib/lhm/table_name.rb
|
240
240
|
- lib/lhm/test_support.rb
|
241
241
|
- lib/lhm/throttler.rb
|
242
|
+
- lib/lhm/throttler/backoff_reduction.rb
|
242
243
|
- lib/lhm/throttler/replica_lag.rb
|
243
244
|
- lib/lhm/throttler/slave_lag.rb
|
244
245
|
- lib/lhm/throttler/threads_running.rb
|