Skip to content

Commit

Permalink
Don't reconnect to send pipelined request no-op
Browse files Browse the repository at this point in the history
If sending the pipelined get commands fails with a network error, the
socket will be closed when we try to send the no-op command. `alive?`
reconnects if possible, but we only need to send the no-op if the get
commands were successfully sent.

Before c01d410, reconnecting to send a
no-op was harmless, but now that pipelined requests are tracked in their
entirety, an error is raised since there is no request in progress.
  • Loading branch information
eugeneius committed Jan 25, 2024
1 parent 025c946 commit 51bf6d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dalli/pipelined_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def finish_queries(servers)
deleted = []

servers.each do |server|
next unless server.alive?
next unless server.connected?

begin
finish_query_for_server(server)
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@
end
end

it 'handles timeout error during pipelined get' do
with_nil_logger do
memcached(p, 19_191) do |dc|
dc.send(:ring).server_for_key('abc').sock.stub(:write, proc { raise Timeout::Error }) do
assert_empty dc.get_multi(['abc'])
end
end
end
end

it 'handles asynchronous Thread#raise' do
with_nil_logger do
memcached(p, 19_191) do |dc|
Expand Down

0 comments on commit 51bf6d5

Please sign in to comment.