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

Fixed blocking command to be timed out based on the specified command argument #1283

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

barshaul
Copy link
Collaborator

Currently, blocking commands are being timed out based on the client's request timeout. Since blocking commands contain a timeout argument, we should use this command-specific timeout to determine when to terminate

@barshaul barshaul requested a review from a team as a code owner April 15, 2024 15:06
@barshaul barshaul marked this pull request as draft April 15, 2024 15:12
@Yury-Fridlyand Yury-Fridlyand linked an issue Apr 15, 2024 that may be closed by this pull request
@barshaul barshaul force-pushed the blocking_cmds branch 2 times, most recently from 400ece5 to 911d098 Compare April 16, 2024 08:09
@barshaul barshaul marked this pull request as ready for review April 16, 2024 08:11
@barshaul barshaul requested a review from ikolomi April 16, 2024 08:11
@barshaul barshaul marked this pull request as draft April 16, 2024 08:15
@barshaul barshaul marked this pull request as ready for review April 16, 2024 08:51
@barshaul barshaul force-pushed the blocking_cmds branch 5 times, most recently from 26cbe61 to c3a67f1 Compare April 16, 2024 13:51
glide-core/tests/test_client.rs Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
@Yury-Fridlyand Yury-Fridlyand added the Rust core redis-rs/glide-core matter label Apr 16, 2024
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/tests/test_client.rs Show resolved Hide resolved
glide-core/tests/test_client.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
node/tests/SharedTests.ts Outdated Show resolved Hide resolved
python/python/tests/test_async_client.py Outdated Show resolved Hide resolved
glide-core/tests/test_client.rs Outdated Show resolved Hide resolved
glide-core/tests/test_client.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
fn get_request_timeout(cmd: &Cmd, default_timeout: Duration) -> Option<Duration> {
let command = cmd.command().unwrap_or_default();
let timeout = match command.as_slice() {
b"BLPOP" | b"BRPOP" | b"BLMOVE" | b"BZPOPMAX" | b"BZPOPMIN" | b"BRPOPLPUSH" => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has potential to miss the future commands having timeouts - we should add reference to this function to the "integrating new-commands" SOP.
In addition we should have an automatic test like this (for redis):

  1. pull the target server commands.json
  2. detect commands with the timeout param
  3. check we handle each command correctly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ikolomi Can you create an issue for that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@barshaul barshaul force-pushed the blocking_cmds branch 6 times, most recently from 2558dd0 to 9e6acd4 Compare April 18, 2024 15:21
@barshaul
Copy link
Collaborator Author

glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

LGTM, but couple of questions left

glide-core/src/client/mod.rs Outdated Show resolved Hide resolved
await redis_client.info(route=ByAddressRoute("foo"))


@pytest.mark.asyncio
Copy link
Collaborator

Choose a reason for hiding this comment

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

good to test: blpop with timeout 1 sec blocks for ~1 sec even if the request timeout set to 100 millis or so

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I test it on the core

@barshaul barshaul force-pushed the blocking_cmds branch 2 times, most recently from c6496a7 to 7eda646 Compare April 21, 2024 12:23
@avifenesh
Copy link
Collaborator

LGTM
But i think there's a point pooping out in result of this PR and other alike.
We are starting to have a lot of points which specific commands need to be added to specific points. Both in redis-rs and both in glide-core, and its create a lot of points-of-failure.
We need to start think how we can create more mature testing facilities which automatically know for a command wether it was added to each point needed or some points were missing.
@ikolomi offer is a good one, but we need to have it more widely to all check, beside time-out (e.g. key-based, routing, legal for pipeline etc.).

@barshaul barshaul merged commit c07100c into valkey-io:main Apr 24, 2024
45 checks passed
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust core redis-rs/glide-core matter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure the timeout of blocking command to be user configured
5 participants