fix(redis sink): treat PUBLISH with 0 subscribers as success#25378
Open
gl-pup wants to merge 2 commits intovectordotdev:masterfrom
Open
fix(redis sink): treat PUBLISH with 0 subscribers as success#25378gl-pup wants to merge 2 commits intovectordotdev:masterfrom
gl-pup wants to merge 2 commits intovectordotdev:masterfrom
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
For Channel data_type, Redis PUBLISH returns the number of subscribers that received the message. When no subscribers are connected (e.g. the consumer momentarily dropped its subscription), Redis returns 0. redis-rs deserializes this integer 0 as bool false into Vec<bool>, causing is_successful() to return false and Vector to retry the same request indefinitely — even though the connection and Redis are healthy. Fix: short-circuit is_successful() to true for DataType::Channel. A zero-subscriber publish is a valid outcome in pub/sub, not an error.
cc51551 to
39a711c
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA. |
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
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.
Summary
The
redissink usingdata_type: channelenters an infinite retry loop when aPUBLISHcommand returns0(no subscribers currently connected).Root cause
Redis
PUBLISHreturns the number of subscribers that received the message as an integer. When no subscribers are connected, Redis returns:0\r\n.redis-rsdeserializes this integer asbool falseintoVec<bool>, causingis_successful()to returnfalse, which triggersshould_retry_responseto returnRetry— even though the connection and Redis server are both healthy.This is fundamentally different from
ListandSortedSetoperations, where a0response would indicate a genuine failure (LPUSH/RPUSHalways returns the new list length ≥ 1 on success).Fix
Short-circuit
is_successful()totrueforDataType::Channel. A zero-subscriber publish is a valid transient state in pub/sub (the consumer may have momentarily dropped its subscription) and must not be treated as an error.ListandSortedSetbehavior is unchanged.Test plan
redis_channel_publish_zero_subscribers_is_successful: verifies thatis_successful()returnstrueforDataType::Channelwhenevent_statuscontainsfalse(0 subscribers)redis_list_and_sorted_set_still_check_event_status: verifies thatListandSortedSetstill treatfalseevent status as failure