8000 Free module context even if there was no content written in auxsave2 by murphyjacob4 · Pull Request #2132 · valkey-io/valkey · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Free module context even if there was no content written in auxsave2 #2132

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

Merged
merged 1 commit into from
May 27, 2025

Conversation

murphyjacob4
Copy link
Contributor
@murphyjacob4 murphyjacob4 commented May 23, 2025

When a module saves to the Aux metadata with aux_save2 callback, the module context is not freed if the module didn't save anything in the callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284. Note that we return 0, however we should be doing the cleanup done on https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303 still.

Fixes #2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Copy link
codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 71.07%. Comparing base (053bf9e) to head (f8fa162).
Report is 10 commits behind head on unstable.

Files with missing lines Patch % Lines
src/rdb.c 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #2132      +/-   ##
============================================
- Coverage     71.18%   71.07%   -0.11%     
============================================
  Files           122      122              
  Lines         66046    66049       +3     
============================================
- Hits          47013    46943      -70     
- Misses        19033    19106      +73     
Files with missing lines Coverage Δ
src/rdb.c 76.78% <0.00%> (+0.48%) ⬆️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor
@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

Fix looks correct to me.

Ideally we should have a test covering this path. There seems to be test code for it in https://github.com/valkey-io/valkey/blob/8.1.1/tests/modules/testrdb.c#L350-L360 and test cases https://github.com/valkey-io/valkey/blob/8.1.1/tests/unit/moduleapi/testrdb.tcl#L30-L57. Why didn't these test cases catch this bug?

@zuiderkwast zuiderkwast added the to-be-merged Almost ready to merge label May 25, 2025
@zuiderkwast zuiderkwast moved this to In Progress in Valkey 7.2 May 25, 2025
@zuiderkwast zuiderkwast moved this to In Progress in Valkey 8.0 May 25, 2025
@zuiderkwast zuiderkwast moved this to In Progress in Valkey 8.1 May 25, 2025
Copy link
Member
@enjoy-binbin enjoy-binbin left a comment

Choose a reason for hiding this comment

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

Make sense to me.

@zuiderkwast
Copy link
Contributor

@murphyjacob4 If the module wants to support older Valkey without this fix, it still needs some workaround for this bug, right?

@zuiderkwast zuiderkwast merged commit 258213f into valkey-io:unstable May 27, 2025
51 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to To be backported in Valkey 7.2 May 27, 2025
@github-project-automation github-project-automation bot moved this from In Progress to To be backported in Valkey 8.0 May 27, 2025
@github-project-automation github-project-automation bot moved this from In Progress to To be backported in Valkey 8.1 May 27, 2025
@zuiderkwast zuiderkwast removed the to-be-merged Almost ready to merge label May 27, 2025
@murphyjacob4
Copy link
Contributor Author
murphyjacob4 commented May 29, 2025

@murphyjacob4 If the module wants to support older Valkey without this fix, it still needs some workaround for this bug, right?

Right. It would be required that, if a module is using auxsave2, the module context is not created from the RDB (via VM_GetContextFromIO https://github.com/valkey-io/valkey/blob/unstable/src/module.c#L7602-L7607) unless some contents are going to be saved to the RDB.

Why didn't these test cases catch this bug?

Looks like we don't create a context in the save path

https://github.com/valkey-io/valkey/blob/8.1.1/tests/modules/testrdb.c#L97-L116

Let me follow up with a test change to catch this

@murphyjacob4
Copy link
Contributor Author

See #2150 for tests

enjoy-binbin pushed a commit that referenced this pull request May 30, 2025
)

See #2132 for the fix.

This just ensures that we always create context in all branches of
aux_load and aux_save

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
hpatro pushed a commit to hpatro/valkey that referenced this pull request Jun 4, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
hpatro pushed a commit to hpatro/valkey that referenced this pull request Jun 4, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
hpatro pushed a commit that referenced this pull request Jun 9, 2025
…2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes #2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
hpatro pushed a commit that referenced this pull request Jun 11, 2025
…2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes #2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
@hpatro hpatro moved this from To be backported to 8.1.2 in Valkey 8.1 Jun 11, 2025
chzhoo pushed a commit to chzhoo/valkey that referenced this pull request Jun 12, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: chzhoo <czawyx@163.com>
chzhoo pushed a commit to chzhoo/valkey that referenced this pull request Jun 12, 2025
…lkey-io#2150)

See valkey-io#2132 for the fix.

This just ensures that we always create context in all branches of
aux_load and aux_save

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: chzhoo <czawyx@163.com>
vitarb pushed a commit to vitarb/valkey that referenced this pull request Jun 12, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
(cherry picked from commit 258213f)
vitarb pushed a commit to vitarb/valkey that referenced this pull request Jun 13, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
(cherry picked from commit 258213f)
shanwan1 pushed a commit to shanwan1/valkey that referenced this pull request Jun 13, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: shanwan1 <shanwan1@intel.com>
shanwan1 pushed a commit to shanwan1/valkey that referenced this pull request Jun 13, 2025
…lkey-io#2150)

See valkey-io#2132 for the fix.

This just ensures that we always create context in all branches of
aux_load and aux_save

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Signed-off-by: shanwan1 <shanwan1@intel.com>
@ranshid ranshid moved this from To be backported to In Progress in Valkey 7.2 Jun 18, 2025
ranshid pushed a commit to ranshid/valkey that referenced this pull request Jun 18, 2025
…alkey-io#2132)

When a module saves to the Aux metadata with aux_save2 callback, the
module context is not freed if the module didn't save anything in the
callback.

https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1277-L1284.
Note that we return 0, however we should be doing the cleanup done on
https://github.com/valkey-io/valkey/blob/8.1.1/src/rdb.c#L1300-L1303
still.

Fixes valkey-io#2125

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Status: To be backported
Status: 8.1.2
Development

Successfully merging this pull request may close these issues.

[CRASH] runtest wait/expire test cases trigger assert failure with default Valkey-Search module loaded.
3 participants
0