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(server): update denyoom flag for all commands #1651

Merged
merged 2 commits into from
Aug 9, 2023
Merged

Conversation

adiholden
Copy link
Collaborator

@adiholden adiholden commented Aug 6, 2023

fixes #1632
DENYOOM command flag marks which commands will be denied when memory usage crosses the "red zone".

Comment on lines -1800 to -1803
*registry << CI{"JSON.NUMINCRBY", CO::WRITE | CO::DENYOOM | CO::FAST, 4, 1, 1, 1}.HFUNC(
NumIncrBy);
*registry << CI{"JSON.NUMMULTBY", CO::WRITE | CO::DENYOOM | CO::FAST, 4, 1, 1, 1}.HFUNC(
NumMultBy);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the policy by which we decide on DENYOOM? What is SETBIT allowed and JSON.NUMINCRBY not?

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://redis.io/commands/json.numincrby/

json.NUMINCRBY increments the already existing field. Besides temporary allocation there is no memory growth here.

*registry << CI{"JSON.CLEAR", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1, 1}.HFUNC(Clear);
*registry << CI{"JSON.ARRPOP", CO::WRITE | CO::DENYOOM | CO::FAST, -3, 1, 1, 1}.HFUNC(ArrPop);
*registry << CI{"JSON.ARRTRIM", CO::WRITE | CO::DENYOOM | CO::FAST, 5, 1, 1, 1}.HFUNC(ArrTrim);
*registry << CI{"JSON.CLEAR", CO::WRITE | CO::FAST, 3, 1, 1, 1}.HFUNC(Clear);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should clear memory, right? So why not allow it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we do allow it, this is why we removed DENYOOM

@@ -1315,14 +1315,13 @@ void ListFamily::Register(CommandRegistry* registry) {
<< CI{"LLEN", CO::READONLY | CO::FAST, 2, 1, 1, 1}.HFUNC(LLen)
<< CI{"LPOS", CO::READONLY | CO::FAST, -3, 1, 1, 1}.HFUNC(LPos)
<< CI{"LINDEX", CO::READONLY, 3, 1, 1, 1}.HFUNC(LIndex)
<< CI{"LINSERT", CO::WRITE, 5, 1, 1, 1}.HFUNC(LInsert)
<< CI{"LINSERT", CO::WRITE | CO::DENYOOM, 5, 1, 1, 1}.HFUNC(LInsert)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can increase memory usage, right? Why allow it then?

Copy link
Contributor

@dranikpg dranikpg Aug 6, 2023

Choose a reason for hiding this comment

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

Reply to all comments above: Its flipped 😄 Deny -> Deny execution in case of oom

romange
romange previously approved these changes Aug 6, 2023
Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

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

@adiholden please explain in the commit that denyoom flag says which commands can not run in the oom state where flag memory usage crosses the "red zone".

dranikpg
dranikpg previously approved these changes Aug 6, 2023
Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

Didn't found conflicting cases from those changed. If only we could somehow reliably DCHECK it... 🤔

@@ -1315,14 +1315,13 @@ void ListFamily::Register(CommandRegistry* registry) {
<< CI{"LLEN", CO::READONLY | CO::FAST, 2, 1, 1, 1}.HFUNC(LLen)
<< CI{"LPOS", CO::READONLY | CO::FAST, -3, 1, 1, 1}.HFUNC(LPos)
<< CI{"LINDEX", CO::READONLY, 3, 1, 1, 1}.HFUNC(LIndex)
<< CI{"LINSERT", CO::WRITE, 5, 1, 1, 1}.HFUNC(LInsert)
<< CI{"LINSERT", CO::WRITE | CO::DENYOOM, 5, 1, 1, 1}.HFUNC(LInsert)
Copy link
Contributor

@dranikpg dranikpg Aug 6, 2023

Choose a reason for hiding this comment

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

Reply to all comments above: Its flipped 😄 Deny -> Deny execution in case of oom

chakaz
chakaz previously approved these changes Aug 6, 2023
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.

🤦
Re/ the failure: it seems unrelated, I just sent out #1653

@adiholden adiholden dismissed stale reviews from chakaz, dranikpg, and romange via f978a37 August 6, 2023 10:41
Signed-off-by: adi_holden <adi@dragonflydb.io>
Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden
Copy link
Collaborator Author

@dranikpg @chakaz can you please approve, unless you have any comment

@adiholden adiholden merged commit 3565e80 into main Aug 9, 2023
10 checks passed
@adiholden adiholden deleted the update_denyoom branch August 9, 2023 06:42
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.

introduce memory guards for memory eating commands
4 participants