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

fix: consume parser error on dfly load #4556

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fix: consume parser error on dfly load #4556

wants to merge 2 commits into from

Conversation

kostasrim
Copy link
Contributor

@kostasrim kostasrim commented Feb 4, 2025

DFLY LOAD triggers the parser's destructor DCHECK which checks if the parsed error was consumed.

Furthermore, fixes dfly load path append nonsense succeeding with ok .

  • fix dcheck crash on dfly load
  • fix dfly load with more than required arguments

IMO do we really need that DCHECK in the destructor ? Sometimes, there is no really reason to even consume it (see this PR as an example).

@kostasrim kostasrim self-assigned this Feb 4, 2025
@@ -533,6 +533,8 @@ void DflyCmd::Load(CmdArgList args, RedisReplyBuilder* rb, ConnectionContext* cn
}

if (parser.HasError()) {
// consume error
parser.Error();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is redundant. Maybe we should remove the DCHECK from the destructor of the parser ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No DCHECK gives us an understanding of whether we check the error or not. Maybe instead of consuming the error we can return a more appropriate error that should be sent via reply builder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I understand what the DCHECK does. All I am saying is that for certain code paths (like the one found here), there is no really a reason to consume the error. On the other hand you can do that in one go if (parse.Error()) to both check for error && consume it which I guess is fine also 🤷

BorysTheDev
BorysTheDev previously approved these changes Feb 4, 2025
@@ -528,11 +528,7 @@ void DflyCmd::Load(CmdArgList args, RedisReplyBuilder* rb, ConnectionContext* cn
existing_keys = ServerFamily::LoadExistingKeys::kOverride;
}

if (parser.HasNext()) {
parser.Error();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, don't consume the error if you have extra arguments. We should reject dfly load path append nonsense :)

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