-
Notifications
You must be signed in to change notification settings - Fork 871
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
bug(streams): fixing xreadgroup's behavior to be compatible with Redis #1908
Conversation
hi @Abhra303 @andydunstall , i saw you implemented the code that I modified... could you please help check if that makes sense? Thanks! |
src/server/stream_family.cc
Outdated
// return NoGroupOrKey error. | ||
// We are simply mimicking Redis' error message here... | ||
// However, we could actually report more precise error message... | ||
(*cntx)->SendError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I didn't want to send an error here because, in case of multiple keys given, we may want to receive entries from existing groups (excluding the non-existent group). Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we do not send error here, I'm afraid that may lead to different behavior than Redis (as it returns error right away if any key or group doesn't exist)? did I miss anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you are right.. i just verified this behavior with Redis, will make a change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Abhra303 after trying more example with Redis, I found Redis also returns no group error as long as there is one group that can't be found for xreadgroup. I tested on Redis with the following unit test (modified from your previous test):
resp = Run({"xreadgroup", "group", "group", "alice", "streams", "mystream", "foo", ">", ">"});
// returns no group error as "group" was not created for mystream.
EXPECT_THAT(resp, ArgType(RespExpr::ERROR));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theyueli, Abrha is mostly working on control plane stuff. Therefore, I prefer that Dragonfly's PRs will be approved by core-team members. @kostasrim , @chakaz , @adiholden are good candidates depending on day of week and holidays :)
You can still consult with Abrhadeep about the changes, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theyueli, Abrha is mostly working on control plane stuff. Therefore, I prefer that Dragonfly's PRs will be approved by core-team members. @kostasrim , @chakaz , @adiholden are good candidates depending on day of week and holidays :)
You can still consult with Abrhadeep about the changes, of course.
sounds good! just tagged the core team members as reviewers.
// However, we could actually report more precise error message... | ||
string error_msg = | ||
NoGroupOrKey(stream, opts->group_name, " in XREADGROUP with GROUP option"); | ||
cntx->transaction->Conclude(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making a general comment here (no need for action on your side on this PR).
I really do not like that we conclude transactions manually, it should be covered in some RAII class such that OnScopeExit it concludes itself. Maybe a good solution for this pattern is the Abseil variant called Cleanup
. And yes I know we conclude before we Send and error but honestly, it won't affect the performance if we literally conclude after we report the error...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really do not like that we conclude transactions manually, it should be covered in some RAII class such that OnScopeExit it concludes itself.
I was asking @romange about doing RAII for this just a moment... I found out I need to conclude transaction so that unit test won't crash..
LGTM |
fixes #1860
Therefore, now:
(used to block for 5 seconds..)
and
(used to return immediately without blocking)