Skip to content
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

Add command "Client Capa subv2" to change behavior for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response #962

Open
wants to merge 9 commits into
base: unstable
Choose a base branch
from

Conversation

hwware
Copy link
Member

@hwware hwware commented Aug 28, 2024

Now for the command SUBSCRIBE and SSUBSCRIBE, if any client call with multiply channels, multiply responses come back.

image

It does not match with the Valkey command response logic, it causes client side to parse the response with extra effort on them. The problem exists long time.

Thus, to fix this design error, I add a new command parameter: client capa subv2
The command "client capa" is imported in Valkey 8, and I add a new parameter "subv2" for it
Note: subv2 is just a temporarily name, I have no idea which name is better, welcome any suggestion.

The update behavior as below: one call with one response

image

Note: for existing users, I think this is a break change. If any client chooses the behavior that one call with one response, the command "client capa subv2" can be called first.

@hwware hwware force-pushed the update-subscribe-command-2-one-reply branch from cbdafa8 to c4fff33 Compare August 28, 2024 14:50
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.52%. Comparing base (20d583f) to head (da1d8d0).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #962      +/-   ##
============================================
- Coverage     70.54%   70.52%   -0.02%     
============================================
  Files           114      114              
  Lines         61644    61652       +8     
============================================
- Hits          43488    43483       -5     
- Misses        18156    18169      +13     
Files with missing lines Coverage Δ
src/pubsub.c 93.69% <100.00%> (-2.66%) ⬇️
src/valkey-cli.c 55.50% <100.00%> (-0.02%) ⬇️

... and 11 files with indirect coverage changes

@hwware hwware changed the title Change behaviour for SUBSCRIBE and SSUBSCRIBE commands: one request with only one response Change behaviour for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response Aug 28, 2024
@hwware hwware changed the title Change behaviour for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response Change behavior for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response Aug 28, 2024
@hwware hwware added the breaking-change Indicates a possible backwards incompatible change label Aug 28, 2024
Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a design error from the beginning, and another design error when RESP3 was introduced, but it is too late to change it now.

This is a serious breaking change that will break all clients that support pubsub. This is very dangerous to do, considering there are many redis-compatible services out there and clients try to be compatible with not only valkey.

if (c->resp == 2)
addReply(c, shared.mbulkhdr[number]);
else
addReplyPushLen(c, number);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with RESP3, this is still no normal in-band replies and one push message (instead of one per channel). This is still the main problem of [UN][P|S]SUBSCRIBE IMO.

To fix this behaviour, SUBSCRIBE should return an in-band reply. Either the list of channels as an array or map-reply, or just +OK and send the channels as push.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not want to import this change in Valkey 8.0. I wish we could do this change on Valkey 8.X or 9 version. Error need to be correct, never late ^_^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we cannot fix it ever. Only maybe with a CLIENT CAPA or RESP4.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with this being a potentially significant breaking change. I think maybe CLIENT CAPA could fix it (or RESP4).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I update the design, add a new parameter for client capa command, but the parameter name is just temporarily. If you have better name, please let me know or we can discuss it in the meeting

@zuiderkwast zuiderkwast added the major-decision-pending Major decision pending by TSC team label Aug 28, 2024
@hwware hwware force-pushed the update-subscribe-command-2-one-reply branch from c4fff33 to 3af8b90 Compare August 29, 2024 14:32
@enjoy-binbin enjoy-binbin added the release-notes This issue should get a line item in the release notes label Sep 4, 2024
@hwware hwware force-pushed the update-subscribe-command-2-one-reply branch 2 times, most recently from 30403a0 to 8bae942 Compare September 12, 2024 14:51
@hwware hwware changed the title Change behavior for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response Add command "Client Capa subv2" to change behavior for SUBSCRIBE and SSUBSCRIBE commands: one call with only one response Sep 12, 2024
@hwware hwware added enhancement New feature or request and removed breaking-change Indicates a possible backwards incompatible change labels Sep 12, 2024
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>
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>
Signed-off-by: hwware <wen.hui.ware@gmail.com>
@hwware hwware force-pushed the update-subscribe-command-2-one-reply branch from 8bae942 to 79f7352 Compare September 16, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major-decision-pending Major decision pending by TSC team release-notes This issue should get a line item in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants