Repository navigation
Fix crash loading a legacy RDB with a deleted document flagged as having a payload - #11607
Conversation
Build a legacy (encver 16) index spec RDB file in the test and start the server from it. Its only document is deleted and flagged as having a payload; the load must drop it and upgrade the index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DocTable_LegacyRdbLoad does not load the payload of a deleted document, but it left Document_HasPayload set on it. Freeing the dropped document then dereferenced its NULL payload in DMD_Free and crashed the server during the RDB load. Clear the flag when the payload is not loaded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9e6922b96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (encver == INDEX_MIN_EXPIRE_VERSION) { | ||
| RedisModule_Free(RedisModule_LoadStringBuffer(rdb, NULL)); // throw this string to garbage |
There was a problem hiding this comment.
Exercise the encver-13 deleted-payload branch
The new fixture hard-codes encoding version 16 with an empty tail, leaving the version-13 compatibility path untested. Version 13 uniquely requires this changed branch to both clear Document_HasPayload and consume the serialized payload string; if either operation regresses, subsequent RDB fields are parsed out of alignment. Add an encver-13 fixture containing a module-string payload and assert that startup succeeds, the upgraded index exists, and it has zero documents.
AGENTS.md reference: AGENTS.md:L22-L22
Useful? React with 👍 / 👎.
Encver 13 is the only encoding that saved the payload of a deleted doc, so its load has to skip that string as well as clear the payload flag. Parameterize the legacy spec fixture by encoding version and cover it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## eyalrund-fix-legacy-byte-offsets-load #11607 +/- ##
======================================================================
Coverage 83.51% 83.52%
======================================================================
Files 665 665
Lines 86545 86546 +1
Branches 40356 40356
======================================================================
+ Hits 72281 72287 +6
+ Misses 13890 13885 -5
Partials 374 374
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
691a4fd
into
eyalrund-fix-legacy-byte-offsets-load



Describe the changes in the pull request
Which additional issues this PR fixes
Main objects this PR modified
DocTable_LegacyRdbLoad(src/doc_table.c): clearsDocument_HasPayloadon deleted documents, whose payload is never loaded. Encver 13 still consumes the saved payload string as before.test_legacy_module_types.py: newtestLegacySpecWithDeletedPayloadDocLoads(encver 16) andtestLegacySpecWithDeletedPayloadDocLoadsExpireEncoding(encver 13, where the deleted document also carries its saved payload string). Each starts the server from a legacy index RDB whose only document is deleted and payload-flagged. The legacy-spec fixture now takes an encoding version.Mark if applicable
Release Notes
Review notes
Why the loader and not
DMD_Free. The loader is what leaves the flag and the pointer out of agreement.DMD_Freeis shared by every document-freeing path, and there it is a valid invariant that a set flag means the payload exists.Related, already fixed.
DocTable_SetPayloadwriting a payload into a document allocated without a payload slot was fixed on master by #11384 (Document_HasPayloadSlot). This PR covers the remaining loader case.Verification. The new test was run in fresh checkouts of the unfixed base and the fix:
DEBUG=1)testLegacySpecWithDeletedPayloadDocLoads(encver 16)DMD_Freeduring the RDB loadtestLegacySpecWithDeletedPayloadDocLoadsExpireEncoding(encver 13)DMD_Freeduring the RDB loadtestRDBCompatibilityover the bundled 1.2-2.0 RDBsFinal runs: base = #11605 tip
1a3675c85, fix =0f0a819ff, one run per regression test. The encver-16 test was also run earlier against mastera26c6a597. Separately, a build that drops the encver-13 string read fails the encver-13 test: Redis rejects the RDB because the fields after it are misread.Performance. One flag update per deleted payload-flagged document, in the legacy loader only. Not measured.
Breaking changes. None identified.
Limitations.
MALLOC=libc, and headers not regenerated (REDISEARCH_GENERATE_HEADERS=0).🤖 Generated with Claude Code