lhm-shopify 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b9ff81249ed6289557c131a6b6183dd77b494af67b71cb4845e69628092801e
4
- data.tar.gz: ca4a71a59985f62685056833ad288a63ff33b0ca233a7a41571cb7f0963b096e
3
+ metadata.gz: 0ef875eccb1a986bb82ef5ee9d981e229ca54fc92e58f61b6e48768928e48baf
4
+ data.tar.gz: d206155bcf16a94c2dc78622826c35b57f7e09b4d9fff1ddad9726d1a48d61fa
5
5
  SHA512:
6
- metadata.gz: ae9eedad45c7425785150927537a604084c60215c1bdfa796e7bc018fdddbaff2e431af97f5611d15ad5064ad9640f4af38c24f44712eb3567a66bba9f128038
7
- data.tar.gz: 67135252c34441946ff069a1c6283545656a60b77306f8e6c019d319f0a164fd17dd898a21fcbfeba5490a52598812a804de52ad5fa498b6eee77a7731bc49ae
6
+ metadata.gz: 6f3c37c8387638aebcdcb3caced88a39b998247a55a130fc8eade81b4c37622af8acdb570e234ce1c3fa25562ec460844e9cc48e9d9d5d1fe4284c9a6d7f4be8
7
+ data.tar.gz: d5a1b197b4260aa494a30de528cdf6e5cfa6e8b81c9f40b40eb9e71fcdcae1c73db6f955d599d5930d581b7c1be7623dc0f96e0112073aa063f178157b1b52c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Unreleased
2
2
 
3
+ # 4.4.1 (Aug, 2024)
4
+ * Extend max_binlog_cache_size exceeded error handling to all throttlers
5
+
3
6
  # 4.4.0 (Aug, 2024)
4
7
  * Add support for retrying chunks when running into max_binlog_cache_size exceeded error
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lhm-shopify (4.4.0)
4
+ lhm-shopify (4.4.1)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.4.0)
4
+ lhm-shopify (4.4.1)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.4.0)
4
+ lhm-shopify (4.4.1)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.4.0)
4
+ lhm-shopify (4.4.1)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -24,7 +24,7 @@ GIT
24
24
  PATH
25
25
  remote: ..
26
26
  specs:
27
- lhm-shopify (4.4.0)
27
+ lhm-shopify (4.4.1)
28
28
  retriable (>= 3.0.0)
29
29
 
30
30
  GEM
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
- handle_max_binlog_exceeded_error
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
@@ -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
- if @backoff_reduction_factor >= 1 || @backoff_reduction_factor <= 0
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
@@ -1,3 +1,4 @@
1
+ require 'lhm/throttler/backoff_reduction'
1
2
  require 'lhm/throttler/time'
2
3
  require 'lhm/throttler/replica_lag'
3
4
  require 'lhm/throttler/slave_lag'
data/lib/lhm/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Schmidt
3
3
 
4
4
  module Lhm
5
- VERSION = '4.4.0'
5
+ VERSION = '4.4.1'
6
6
  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: 4.4.0
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-20 00:00:00.000000000 Z
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