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

Notes on what *SUBSCRIBE returns (or doesn't return) #2327

Merged
merged 5 commits into from Feb 23, 2023

Conversation

zuiderkwast
Copy link
Contributor

See related discussion in redis/redis#11784.

@netlify
Copy link

netlify bot commented Feb 16, 2023

👷 Deploy request for redis-doc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1978cec

Copy link
Member

@itamarhaber itamarhaber left a comment

Choose a reason for hiding this comment

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

Thanks @zuiderkwast - I agree this helps.

  1. Although these return nothing, I'd like to have a @return before the void's description for consistency. WDUT?
  2. "Once the client enters..." - I know it is copied from subscribe, but I wonder about that statement's correctness when in RESP3. Perhaps we should make the distinction?

@zuiderkwast
Copy link
Contributor Author

  1. Although these return nothing, I'd like to have a @return before the void's description for consistency. WDUT?

Just a @return to add the heading? That's a good idea.

  1. "Once the client enters..." - I know it is copied from subscribe, but I wonder about that statement's correctness when in RESP3. Perhaps we should make the distinction?

RESP3 doesn't have this limitation (if the void-or-error return value is handled correctly) but I think we can keep this around just like for SUBSCRIBE until we have a better recommendation. Better safe than sorry.

Would you like to formulate a better recommendation that I can paste here? 😀

I guess we would need to split this recommendation into one for RESP2 and one for RESP3, but I don't know if there is anywhere we can link to for more info about RESP3. Perhaps we can link to the HELLO command?

@zuiderkwast zuiderkwast changed the title Notes an what *SUBSCRIBE returns (or doesn't return) Notes on what *SUBSCRIBE returns (or doesn't return) Feb 20, 2023
@zuiderkwast
Copy link
Contributor Author

@itamarhaber would you like to have another look? I've added notes about RESP3.

@zuiderkwast zuiderkwast added the to-be-merged should probably be merged soon label Feb 23, 2023
@@ -7,3 +7,16 @@ Supported glob-style patterns:
* `h[ae]llo` subscribes to `hello` and `hallo,` but not `hillo`

Use `\` to escape special characters if you want to match them verbatim.

Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`, `PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands.
Copy link
Collaborator

@ranshid ranshid Feb 19, 2023

Choose a reason for hiding this comment

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

this is true only for resp2 right? maybe we should add that fact to the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx for comment.

The next line (line 12) says "However, if RESP3 is used (see HELLO) it is possible for a client to issue any commands while in subscribed state.". Is this not clear enough? Should we explicitly mention RESP2 in the first sentence?

Since RESP2 is the default protocol, I thought we can mention the differences for RESP3 afterwards like this, but if you have better idea, I'm happy to change.

Btw, RESP3 is not even documented on this website yet. Itamar has a WIP PR #2120 adding the RESP3 protocol spec. Until that is merged, we don't have anywhere to link for more information about RESP3 types (push, etc.) so I think we can update these commands' docs again after the RESP3 PR is merged.

In general, we will need to figure out how we want to document the difference in RESP2 vs RESP3 for each command. For other commands we have no documentation at all for RESP3, such as that HGETALL returns a hash or that SUNION returns a set. IMO we should change this to 'returns a hash' and 'returns a set' and in the protocol spec explain how these are represented in RESP2 and RESP3, rather than explaining this on each command's doc page.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow to be honest I missed the following line since it does not apear in the published docs (AFAIK) I only stated it since I know currently people are missing that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll merge this as it is then?

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -4,6 +4,13 @@ Once the client enters the subscribed state it is not supposed to issue any
other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`,
`PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we would like to explain that this is only true for resp2?

@zuiderkwast zuiderkwast merged commit 7310463 into redis:master Feb 23, 2023
@zuiderkwast zuiderkwast deleted the subscribe-return branch February 23, 2023 13:47
oranagra added a commit to redis/redis that referenced this pull request Mar 12, 2023
…ons (#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes #11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
oranagra pushed a commit to redis/redis that referenced this pull request Mar 12, 2023
…IBE/SUNSUBSCRIBE (#11047)

In unsubscribe related commands, we need to read the specified
number of replies according to the number of parameters.

These commands may return multiple RESP replies, and currently
redis-cli only tries to read only one reply.

Fixes #11046, this redis-cli bug seems to be there forever.
Note that the [UN]SUBSCRIBE command response is a bit awkward
see: redis/redis-doc#2327
oranagra pushed a commit to oranagra/redis that referenced this pull request Mar 20, 2023
…ons (redis#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes redis#11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
oranagra pushed a commit to redis/redis that referenced this pull request Mar 20, 2023
…ons (#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes #11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
Mixficsol pushed a commit to Mixficsol/redis that referenced this pull request Apr 12, 2023
…ons (redis#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes redis#11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
Mixficsol pushed a commit to Mixficsol/redis that referenced this pull request Apr 12, 2023
…IBE/SUNSUBSCRIBE (redis#11047)

In unsubscribe related commands, we need to read the specified
number of replies according to the number of parameters.

These commands may return multiple RESP replies, and currently
redis-cli only tries to read only one reply.

Fixes redis#11046, this redis-cli bug seems to be there forever.
Note that the [UN]SUBSCRIBE command response is a bit awkward
see: redis/redis-doc#2327
oranagra pushed a commit to oranagra/redis that referenced this pull request Apr 17, 2023
…ons (redis#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes redis#11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
(cherry picked from commit f8ae7a4)
oranagra pushed a commit to oranagra/redis that referenced this pull request Apr 17, 2023
…ons (redis#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes redis#11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
(cherry picked from commit f8ae7a4)
(cherry picked from commit 96814a32da61e5ed523864e00609a4aa6be065b3)
oranagra pushed a commit to redis/redis that referenced this pull request Apr 17, 2023
…ons (#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes #11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
(cherry picked from commit f8ae7a4)
(cherry picked from commit 96814a32da61e5ed523864e00609a4aa6be065b3)
oranagra pushed a commit to redis/redis that referenced this pull request Apr 17, 2023
…ons (#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes #11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 416842e)
(cherry picked from commit f8ae7a4)
enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
…ons (redis#11875)

This bug seems to be there forever, CLIENT REPLY OFF|SKIP will
mark the client with CLIENT_REPLY_OFF or CLIENT_REPLY_SKIP flags.
With these flags, prepareClientToWrite called by addReply* will
return C_ERR directly. So the client can't receive the Pub/Sub
messages and any other push notifications, e.g client side tracking.

In this PR, we adding a CLIENT_PUSHING flag, disables the reply
silencing flags. When adding push replies, set the flag, after the reply,
clear the flag. Then add the flag check in prepareClientToWrite.

Fixes redis#11874

Note, the SUBSCRIBE command response is a bit awkward,
see redis/redis-doc#2327

Co-authored-by: Oran Agra <oran@redislabs.com>
enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
…IBE/SUNSUBSCRIBE (redis#11047)

In unsubscribe related commands, we need to read the specified
number of replies according to the number of parameters.

These commands may return multiple RESP replies, and currently
redis-cli only tries to read only one reply.

Fixes redis#11046, this redis-cli bug seems to be there forever.
Note that the [UN]SUBSCRIBE command response is a bit awkward
see: redis/redis-doc#2327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-be-merged should probably be merged soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants