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

valkey-cli auto-exit from subscribed mode #1432

Merged
merged 20 commits into from
Jan 8, 2025

Conversation

Nikhil-Manglore
Copy link
Contributor

@Nikhil-Manglore Nikhil-Manglore commented Dec 12, 2024

Resolves issue with valkey-cli not auto exiting from subscribed mode on reaching zero pub/sub subscription (previously filed on Redis) redis/redis#12592

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.89%. Comparing base (b3b4bdc) to head (fe091cf).
Report is 7 commits behind head on unstable.

Files with missing lines Patch % Lines
src/valkey-cli.c 96.29% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1432      +/-   ##
============================================
+ Coverage     70.83%   70.89%   +0.05%     
============================================
  Files           120      120              
  Lines         64911    64980      +69     
============================================
+ Hits          45982    46069      +87     
+ Misses        18929    18911      -18     
Files with missing lines Coverage Δ
src/valkey-cli.c 55.85% <96.29%> (+0.36%) ⬆️

... and 50 files with indirect coverage changes

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.

Hello! Welcome to Valkey!

I remember this issue. :)

src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
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.

Logic looks correct, but I have two comments.

I think it would be good to add a test for valkey-cli that uses SUBSCRIBE, PSUBSCRIBE, SSUBSCRIBE in the same session, an exits pubsub mode when all three are unsubscribed.

src/valkey-cli.c Outdated Show resolved Hide resolved
tests/unit/pubsub.tcl Outdated Show resolved Hide resolved
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.

Good, thanks. I have some new comments. :)

src/valkey-cli.c Outdated Show resolved Hide resolved
tests/integration/valkey-cli.tcl Outdated Show resolved Hide resolved
tests/integration/valkey-cli.tcl Outdated Show resolved Hide resolved
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.

It's getting better! I'm not sure if check for "(subscribed mode)" in the prompt works as intended though.

Maybe we need to test this in some other way. If you can't solve it, then I'll try to think of something.

src/valkey-cli.c Outdated Show resolved Hide resolved
tests/integration/valkey-cli.tcl Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
tests/integration/valkey-cli.tcl Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
Signed-off-by: Nikhil Manglore <[email protected]>
Signed-off-by: Nikhil Manglore <[email protected]>
Signed-off-by: Nikhil Manglore <[email protected]>
src/valkey-cli.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@hpatro hpatro left a comment

Choose a reason for hiding this comment

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

LGTM overall. minor nitpicks.

src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
src/valkey-cli.c Outdated Show resolved Hide resolved
@zuiderkwast
Copy link
Contributor

The clang-format CI job is complaining about trailing whitespace. See https://github.com/valkey-io/valkey/actions/runs/12676568798/job/35330205216?pr=1432

To fix it, you can run clang-format -i src/valkey-cli.c or just manually read the diff suggested by clang-format CI job.

Signed-off-by: Nikhil Manglore <[email protected]>
Signed-off-by: Nikhil Manglore <[email protected]>
@Nikhil-Manglore
Copy link
Contributor Author

Nikhil-Manglore commented Jan 8, 2025

I just realized one of the external tests seems to fail here in the checks but always passes locally. Do you know why this could be occurring?

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.

Thanks for your patience!

@zuiderkwast
Copy link
Contributor

I just realized one of the external tests seems to fail here in the checks but always passes locally. Do you know why this could be occurring?

I don't know. I think some github runners are slow or there are some other problems. The failures are not related to this PR.

@zuiderkwast zuiderkwast changed the title valkey-cli doesn't auto exit from subscribed mode on reaching zero subscription valkey-cli auto exit from subscribed mode on reaching zero subscriptions Jan 8, 2025
@zuiderkwast zuiderkwast changed the title valkey-cli auto exit from subscribed mode on reaching zero subscriptions valkey-cli auto-exit from subscribed mode Jan 8, 2025
@zuiderkwast zuiderkwast merged commit 9e02049 into valkey-io:unstable Jan 8, 2025
46 of 48 checks passed
@hpatro
Copy link
Collaborator

hpatro commented Jan 8, 2025

Thanks @Nikhil-Manglore for working on this!

@Nikhil-Manglore Nikhil-Manglore deleted the subscribe-mode-bug branch January 8, 2025 22:17
@Nikhil-Manglore Nikhil-Manglore restored the subscribe-mode-bug branch January 8, 2025 23:08
@Nikhil-Manglore Nikhil-Manglore deleted the subscribe-mode-bug branch January 8, 2025 23:13
enjoy-binbin pushed a commit that referenced this pull request Jan 12, 2025
The commands used in valkey-cli tests are not important the reply schema
validation. Skip them to avoid the problem if tests hanging. This has
failed lately in the daily job:

```
[TIMEOUT]: clients state report follows.
sock55fedcc19be0 => (IN PROGRESS) valkey-cli pubsub mode with single standard channel subscription
Killing still running Valkey server 33357
```

These test cases use a special valkey-cli command `:get pubsub` command,
which is an internal command to valkey-cli rather than a Valkey server
command. This command hangs when compiled with with logreqres enabled.
Easy solution is to skip the tests in this setup.

The test cases were introduced in #1432.

Signed-off-by: Viktor Söderqvist <[email protected]>
proost pushed a commit to proost/valkey that referenced this pull request Jan 17, 2025
Resolves issue with valkey-cli not auto exiting from subscribed mode on
reaching zero pub/sub subscription (previously filed on Redis)
redis/redis#12592

---------

Signed-off-by: Nikhil Manglore <[email protected]>
Signed-off-by: proost <[email protected]>
proost pushed a commit to proost/valkey that referenced this pull request Jan 17, 2025
The commands used in valkey-cli tests are not important the reply schema
validation. Skip them to avoid the problem if tests hanging. This has
failed lately in the daily job:

```
[TIMEOUT]: clients state report follows.
sock55fedcc19be0 => (IN PROGRESS) valkey-cli pubsub mode with single standard channel subscription
Killing still running Valkey server 33357
```

These test cases use a special valkey-cli command `:get pubsub` command,
which is an internal command to valkey-cli rather than a Valkey server
command. This command hangs when compiled with with logreqres enabled.
Easy solution is to skip the tests in this setup.

The test cases were introduced in valkey-io#1432.

Signed-off-by: Viktor Söderqvist <[email protected]>
Signed-off-by: proost <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants