redis-cluster-client 0.11.2 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ce265da4f3a871e187b651c27ce9ee1d9a9321e346c2b1c3d1eba6f40139192
4
- data.tar.gz: 95252d4d8b20e77a3bcc91035208c3d9baafbf2ad31d60adaa4376b38c75c2fa
3
+ metadata.gz: f72e0ed5a40d8d663d00a29ffb43ec046d911c73e514fa709f907eaf59d2e751
4
+ data.tar.gz: 442e3c7ef0e59dbef1950eb661aaf4441226927d4c871ae9a81824b33c456c4e
5
5
  SHA512:
6
- metadata.gz: b2b7b9f733569fe7ba66dc4d49241ac827e6c3e23ea74fa9a04efbb985b601ca575302b8316e891160896d880cc74a2bdb3b88533478cbdab8e1e90b6d2d8926
7
- data.tar.gz: a7982da3ad7a8a373f1ce9993262a279e50889be71bdc5913806da006a9252b65d3574bf816bc2ddb98f0034b6195890c23486eb2155d2ca8a6785753c3f69f1
6
+ metadata.gz: 3c06f2218983448bba3daef5209828aec9b236757094a9635e514519adf0757385f91c8c7d9a62a86d6eb9bf652e9b354a71c457a60208793c63ebd43c14c3d0
7
+ data.tar.gz: 523b7c8b897329260cacf1ab03ba26f917aa8dea0a78682d3aeeb8da538bed87ee482ed4f8e8db6e8f1d63649447b664cd86360f0a7e8bb554f4457d451c0946
@@ -37,8 +37,8 @@ class RedisClient
37
37
  end
38
38
 
39
39
  @errors = errors
40
- messages = @errors.map { |node_key, error| "#{node_key}: #{error.message}" }
41
- super("Errors occurred on any node: #{messages.join(', ')}")
40
+ messages = @errors.map { |node_key, error| "#{node_key}: (#{error.class}) #{error.message}" }
41
+ super(messages.join(', '))
42
42
  end
43
43
  end
44
44
 
@@ -33,7 +33,7 @@ class RedisClient
33
33
  raise
34
34
  end
35
35
  rescue ::RedisClient::CommandError => e
36
- @router.renew_cluster_state if e.message.start_with?('CLUSTERDOWN Hash slot not served')
36
+ @router.renew_cluster_state if e.message.start_with?('CLUSTERDOWN')
37
37
  raise
38
38
  end
39
39
  rescue ::RedisClient::ConnectionError
@@ -73,7 +73,7 @@ class RedisClient
73
73
  first_exception ||= result
74
74
  end
75
75
 
76
- stale_cluster_state = true if result.message.start_with?('CLUSTERDOWN Hash slot not served')
76
+ stale_cluster_state = true if result.message.start_with?('CLUSTERDOWN')
77
77
  end
78
78
 
79
79
  results[index] = result
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'redis_client'
4
+ require 'redis_client/cluster/errors'
4
5
  require 'redis_client/cluster/normalized_cmd_name'
5
6
 
6
7
  class RedisClient
@@ -89,13 +90,10 @@ class RedisClient
89
90
 
90
91
  case event = @queue.pop(true)
91
92
  when ::RedisClient::CommandError
92
- raise event unless event.message.start_with?('MOVED', 'CLUSTERDOWN Hash slot not served')
93
+ raise event unless event.message.start_with?('MOVED', 'CLUSTERDOWN')
93
94
 
94
- @router.renew_cluster_state
95
- break start_over
96
- when ::RedisClient::ConnectionError
97
- @router.renew_cluster_state
98
95
  break start_over
96
+ when ::RedisClient::ConnectionError then break start_over
99
97
  when StandardError then raise event
100
98
  when Array then break event
101
99
  end
@@ -151,25 +149,23 @@ class RedisClient
151
149
  def handle_connection_error(node_key, ignore: false)
152
150
  yield
153
151
  rescue ::RedisClient::ConnectionError
154
- @state_dict[node_key].close
152
+ @state_dict[node_key]&.close
155
153
  @state_dict.delete(node_key)
156
154
  @router.renew_cluster_state
157
155
  raise unless ignore
158
156
  end
159
157
 
160
158
  def start_over
161
- @state_dict.each_value(&:close)
162
- @state_dict.clear
163
- @commands.each do |command|
164
- loop do
165
- _call(command)
166
- break
167
- rescue ::RedisClient::ConnectionError
168
- sleep 1.0
169
- end
159
+ loop do
160
+ @router.renew_cluster_state
161
+ @state_dict.each_value(&:close)
162
+ @state_dict.clear
163
+ @queue.clear
164
+ @commands.each { |command| _call(command) }
165
+ break
166
+ rescue ::RedisClient::ConnectionError, ::RedisClient::Cluster::NodeMightBeDown
167
+ sleep 1.0
170
168
  end
171
-
172
- nil
173
169
  end
174
170
  end
175
171
  end
@@ -29,7 +29,7 @@ class RedisClient
29
29
  @pool = pool
30
30
  @client_kwargs = kwargs
31
31
  @node = ::RedisClient::Cluster::Node.new(concurrent_worker, config: config, pool: pool, **kwargs)
32
- renew_cluster_state
32
+ @node.reload!
33
33
  @command = ::RedisClient::Cluster::Command.load(@node.replica_clients.shuffle, slow_command_timeout: config.slow_command_timeout)
34
34
  @command_builder = @config.command_builder
35
35
  end
@@ -74,7 +74,7 @@ class RedisClient
74
74
  renew_cluster_state
75
75
  raise
76
76
  rescue ::RedisClient::CommandError => e
77
- renew_cluster_state if e.message.start_with?('CLUSTERDOWN Hash slot not served')
77
+ renew_cluster_state if e.message.start_with?('CLUSTERDOWN')
78
78
  raise
79
79
  rescue ::RedisClient::Cluster::ErrorCollection => e
80
80
  raise if e.errors.any?(::RedisClient::CircuitBreaker::OpenCircuitError)
@@ -82,7 +82,7 @@ class RedisClient
82
82
  renew_cluster_state if e.errors.values.any? do |err|
83
83
  next false if ::RedisClient::Cluster::ErrorIdentification.identifiable?(err) && @node.none? { |c| ::RedisClient::Cluster::ErrorIdentification.client_owns_error?(err, c) }
84
84
 
85
- err.message.start_with?('CLUSTERDOWN Hash slot not served') || err.is_a?(::RedisClient::ConnectionError)
85
+ err.message.start_with?('CLUSTERDOWN') || err.is_a?(::RedisClient::ConnectionError)
86
86
  end
87
87
 
88
88
  raise
@@ -123,7 +123,7 @@ class RedisClient
123
123
  node.call('ASKING')
124
124
  retry
125
125
  end
126
- elsif e.message.start_with?('CLUSTERDOWN Hash slot not served')
126
+ elsif e.message.start_with?('CLUSTERDOWN')
127
127
  renew_cluster_state
128
128
  retry if retry_count >= 0
129
129
  end
@@ -241,6 +241,8 @@ class RedisClient
241
241
 
242
242
  def renew_cluster_state
243
243
  @node.reload!
244
+ rescue ::RedisClient::Cluster::InitialSetupError
245
+ # ignore
244
246
  end
245
247
 
246
248
  def close
@@ -170,7 +170,7 @@ class RedisClient
170
170
  elsif err.message.start_with?('ASK')
171
171
  node = @router.assign_asking_node(err.message)
172
172
  try_asking(node) ? send_transaction(node, redirect: redirect - 1) : err
173
- elsif err.message.start_with?('CLUSTERDOWN Hash slot not served')
173
+ elsif err.message.start_with?('CLUSTERDOWN')
174
174
  @router.renew_cluster_state if @watching_slot.nil?
175
175
  raise err
176
176
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-26 00:00:00.000000000 Z
11
+ date: 2024-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client