Skip to content

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

@codecov
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Signed-off-by: Harkrishn Patro <[email protected]>
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 <[email protected]>
Signed-off-by: Harkrishn Patro <[email protected]>
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 <[email protected]>
Signed-off-by: Harkrishn Patro <[email protected]>
@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 <[email protected]>
Signed-off-by: chzhoo <[email protected]>
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 <[email protected]>
Signed-off-by: chzhoo <[email protected]>
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 <[email protected]>
(cherry picked from commit 258213f)
@vitarb vitarb mentioned this pull request Jun 13, 2025
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 <[email protected]>
(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 <[email protected]>
Signed-off-by: shanwan1 <[email protected]>
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 <[email protected]>
Signed-off-by: shanwan1 <[email protected]>
@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 <[email protected]>
ranshid pushed a commit to ranshid/valkey that referenced this pull request Jun 22, 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 <[email protected]>
ranshid pushed a commit that referenced this pull request Jul 7, 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 <[email protected]>
zuiderkwast pushed a commit to vitarb/valkey that referenced this pull request Aug 15, 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 <[email protected]>
(cherry picked from commit 258213f)
zuiderkwast pushed a commit to vitarb/valkey that referenced this pull request Aug 15, 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 <[email protected]>
(cherry picked from commit 258213f)
Signed-off-by: Viktor Söderqvist <[email protected]>
@zuiderkwast zuiderkwast moved this from To be backported to 8.0.5 in Valkey 8.0 Aug 18, 2025
zuiderkwast pushed a commit to vitarb/valkey that referenced this pull request Aug 21, 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 <[email protected]>
(cherry picked from commit 258213f)
Signed-off-by: Viktor Söderqvist <[email protected]>
zuiderkwast pushed a commit that referenced this pull request Aug 22, 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 <[email protected]>
(cherry picked from commit 258213f)
Signed-off-by: Viktor Söderqvist <[email protected]>
sarthakaggarwal97 pushed a commit to sarthakaggarwal97/valkey that referenced this pull request Sep 16, 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 <[email protected]>
(cherry picked from commit 258213f)
Signed-off-by: Viktor Söderqvist <[email protected]>
@rainsupreme rainsupreme moved this from In Progress to 7.2.10 in Valkey 7.2 Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 7.2.10
Status: 8.0.5
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