fix(redis): expect a single ack count for targeted broadcast with ack - #782
Open
LiamCarPer wants to merge 1 commit into
Open
fix(redis): expect a single ack count for targeted broadcast with ack#782LiamCarPer wants to merge 1 commit into
LiamCarPer wants to merge 1 commit into
Conversation
When `BroadcastOptions::server_id` is set, the request is sent to this server only, so only one server answers. The expected ack count was still `server_count - 1`, making the ack stream wait for the request timeout before terminating when there are 3+ servers. With 2 servers the targeted count happens to be equal to `server_count - 1`, which is why it went unnoticed. `get_res` already handles a targeted request this way. Adds a regression test with 3 servers asserting the targeted ack stream terminates right after the ack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a redis adapter bug i noticed while working on #774 (thanks for asking for a separate PR for it).
Motivation
When
BroadcastOptions::server_idis set (broadcasting to a remote socket), redis sends the ack request to that server only, but the expected ack count was alwaysserver_count - 1.With 3+ servers only one server answers, so the ack stream does not terminate cleanly and waits for the request timeout instead.
With 2 servers the targeted count happens to be equal to
server_count - 1, which is why this went unnoticed: the existingremote_socket_emit_with_acktest never awaits the acks.Solution
get_resalready handles a targeted request this way, so I mirrored it inbroadcast_with_ack:Added
remote_socket_emit_with_ack_targeted_terminatesincrates/socketioxide-redis/tests/sockets.rs: spawns 3 servers, emits with ack to the remote sockets (echoing the acks from the fake clients) and asserts the stream is terminated right after the ack. It fails before the fix and passes after.No behavior or wire format change for the non targeted case.