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

chore: fix bugs in stream_family #4237

Merged
merged 1 commit into from
Dec 2, 2024
Merged

chore: fix bugs in stream_family #4237

merged 1 commit into from
Dec 2, 2024

Conversation

romange
Copy link
Collaborator

@romange romange commented Dec 2, 2024

  1. Use transaction time in streams code, similarly to how we do it in other commands. Stop using mstime() and delete unused redis code.
  2. Check for sequence overflow issue when passing huge sequence ids. Add a test.

@romange romange requested a review from chakaz December 2, 2024 03:24
@@ -40,4 +47,25 @@ RandomPick UniquePicksGenerator::Generate() {
return max_index;
}

streamConsumer* StreamCreateConsumer(streamCG* cg, string_view name, uint64_t now_ms, int flags) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved here from t_stream because we pass now_ms (the only differrence) instead of calling directly mstime().
In later versions of Redis/Valkey they also switched to "command time" by callng a global getter. Dragonfly uses transactional time

Copy link
Collaborator

Choose a reason for hiding this comment

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

there's another difference, which is that we now accept name as a string_view (which is better! but another difference :)
This also explains why below we don't need to free()

1. Use transaction time in streams code, similarly to how we do it in other commands.
   Stop using mstime() and delete unused redis code.
2. Check for sequence overflow issue when passing huge sequence ids.
   Add a test.

Signed-off-by: Roman Gershman <[email protected]>
Copy link
Collaborator

@chakaz chakaz left a comment

Choose a reason for hiding this comment

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

Nice! I would imagine that making such a change will require way more patching :)

@@ -40,4 +47,25 @@ RandomPick UniquePicksGenerator::Generate() {
return max_index;
}

streamConsumer* StreamCreateConsumer(streamCG* cg, string_view name, uint64_t now_ms, int flags) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's another difference, which is that we now accept name as a string_view (which is better! but another difference :)
This also explains why below we don't need to free()

@@ -563,15 +560,16 @@ int StreamAppendItem(stream* s, CmdArgList fields, streamID* added_id, streamID*
s->first_id = id;
if (added_id)
*added_id = id;
return C_OK;

return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not return C_OK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

C_OK/C_ERR are redis constants, EDOM/ERANGE are posix constants, so i wanted to reduce this spaghetti

@romange romange merged commit 91aff49 into main Dec 2, 2024
9 checks passed
@romange romange deleted the Pr15 branch December 2, 2024 09:57
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.

2 participants