-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decline unsubscribe related command in non-subscribed mode #759
Decline unsubscribe related command in non-subscribed mode #759
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #759 +/- ##
============================================
- Coverage 70.63% 70.60% -0.03%
============================================
Files 112 112
Lines 61509 61512 +3
============================================
- Hits 43444 43429 -15
- Misses 18065 18083 +18
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. We can discuss the exact error message.
I'm not sure we can call it a bug, but it is at least unexpected behaviour when called with more than one channel. I prefer we decribe it as changing an unexpected behaviour rather than a bugfix.
Whatever it is a bug or unexpected behavior, this is a design error. Thus we need to fix it and make the right turn. |
caa1874
to
cd67cb8
Compare
Signed-off-by: hwware <wen.hui.ware@gmail.com>
Signed-off-by: hwware <wen.hui.ware@gmail.com>
Signed-off-by: hwware <wen.hui.ware@gmail.com>
Signed-off-by: hwware <wen.hui.ware@gmail.com>
cd67cb8
to
9002627
Compare
Now, when clients run the unsubscribe, sunsubscribe and punsubscribe commands in the non-subscribed mode, it returns 0. Indeed this is a bug, we should not allow client run these kind of commands here. Thus, this PR fixes this bug, but it is a break change for existing clients --------- Signed-off-by: hwware <wen.hui.ware@gmail.com>
Now, when clients run the unsubscribe, sunsubscribe and punsubscribe commands in the non-subscribed mode, it returns 0. Indeed this is a bug, we should not allow client run these kind of commands here. Thus, this PR fixes this bug, but it is a break change for existing clients --------- Signed-off-by: hwware <wen.hui.ware@gmail.com>
This change introduced a race condition related to slot migration of sharded channel and at the same time client sending sunsubscribe, which can lead to the client getting out of sync in matching each reply to each command sent. When a slot is migrated, the shard-channels are automatically usubscribed and clients will receive a spontaneous sunsubscribed message (push in RESP3) for each channel in the migrated slot. If the client also manually unsubscribes at the same time, the client can believe the spontaneous sunsubscribed response is a response to the SUNSUBSCRIBE command, but later it will receive an extra -NOSUB error after this PR. The client will believe this error is the response to the next command sent, such as Scenario diagram:
An error reply is always in-band, i.e. it is always for a command. If a client ignores errors for a command like subscribe and unsubscribe, then these commands get no in-band replies and one or more push replies. But there is an error, then subscribe/unsibscribe commands receives an in-band reply. Therefore, a correct client which sends But the above scenario with -NOSUB error breaks this logic. Now, there is no way for a client to make sure it stays in sync. Therefore, I think we should maybe revert this PR. Without this PR, the client will instead in this scenario receive two 'sunsubscribed' push messages. Two push messages are easy to handle without getting out of sync. |
As stated before this breaks clients, one example is |
Perform the punsubscribe before entering non-pubsub mode since Valkey 8 dont allow several UNSUBSCRIBE commands executed under non-pubsub mode. See valkey-io/valkey#759 Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
I made a test case to verify this. Actually, the corner case exists since before, ever since we added the sponaneous sunsubscribe message (when sharded pubsub was introduced?). After moving a slot and the client has received a sunsubscribe message, the SUNSUBSCRIBE command doesn't get a NOSUB error but a MOVED error, or a CLUSTERDOWN if the slot was deleted. I simulated it with the following scenario, where Client 1 can be assumed to not have read the first message when it sends the SUNSUBSCRIBE command. Client 1 then believes that the
I don't see any way for a client to protect itself against this scenario. @bjosv do you? |
No, I don't think there is a way to protect against this currently.. |
Perform the punsubscribe before entering non-pubsub mode since Valkey 8 dont allow several UNSUBSCRIBE commands executed under non-pubsub mode. See valkey-io/valkey#759 Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
…1265) This PR goal is to revert the changes on PR #759 Recently, we got some reports that in Valkey 8.0 the PR #759 (Decline unsubscribe related command in non-subscribed mode) causes break change. (#1228) Although from my thought, call commands "unsubscribeCommand", "sunsubscribeCommand", "punsubscribeCommand" in request-response mode make no sense. This is why I created PR #759 But breaking change is always no good, @valkey-io/core-team How do you think we revert this PR code changes? Signed-off-by: hwware <wen.hui.ware@gmail.com>
…alkey-io#1265) This PR goal is to revert the changes on PR valkey-io#759 Recently, we got some reports that in Valkey 8.0 the PR valkey-io#759 (Decline unsubscribe related command in non-subscribed mode) causes break change. (valkey-io#1228) Although from my thought, call commands "unsubscribeCommand", "sunsubscribeCommand", "punsubscribeCommand" in request-response mode make no sense. This is why I created PR valkey-io#759 But breaking change is always no good, @valkey-io/core-team How do you think we revert this PR code changes? Signed-off-by: hwware <wen.hui.ware@gmail.com>
…alkey-io#1265) This PR goal is to revert the changes on PR valkey-io#759 Recently, we got some reports that in Valkey 8.0 the PR valkey-io#759 (Decline unsubscribe related command in non-subscribed mode) causes break change. (valkey-io#1228) Although from my thought, call commands "unsubscribeCommand", "sunsubscribeCommand", "punsubscribeCommand" in request-response mode make no sense. This is why I created PR valkey-io#759 But breaking change is always no good, @valkey-io/core-team How do you think we revert this PR code changes? Signed-off-by: hwware <wen.hui.ware@gmail.com>
Now, when clients run the unsubscribe, sunsubscribe and punsubscribe commands in the non-subscribed mode, it returns 0.
Indeed this is a bug, we should not allow client run these kind of commands here.
Thus, this PR fixes this bug, but it is a break change for existing clients
Update
This was introduced in Valkey8, and it is a breaking change, this will be revert in #1265