Repository navigation
[2.10] [MOD-15685] Fix crash when a legacy index spec is restored after a failed replication sync - #11621
Conversation
…iled replication sync (#11619) [MOD-15685] Refuse a legacy index spec RESTORE after a failed load The guard added in #10872 refused a legacy ft_index0 load when the legacy-spec registry or the UPGRADE_INDEX rules were NULL, taking that as "no load in progress". A failed load breaks that assumption: LOADING_FAILED clears the loading flag but frees neither global, and the rules are only ever freed by a successful load. On a server that has not completed a load since startup - for example a replica whose first full sync failed and was then promoted - a RESTORE of a truncated legacy payload got past the guard and crashed on the NULL spec name. Key the refusal on g_isLoading as well. The new test drives exactly that sequence against a fake master; it crashes the server without the fix. Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit b1b6903)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2bbe622f40
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // publishes it runs when the load ends. Outside one - a RESTORE of a legacy payload on a running | ||
| // server, say - refuse, so the caller sees a load failure, which for RESTORE is a command error. | ||
| // The globals alone are not enough: a failed load leaves both allocated. | ||
| if (!g_isLoading || legacySpecRules == NULL || legacySpecDict == NULL) { |
There was a problem hiding this comment.
Clear the loading flag after failed loads in non-MT builds
In the default non-MT build, this guard still permits the crashing path after a failed replication sync: Indexes_LoadingEvent sets g_isLoading at load start, but its LOADING_FAILED branch (including the reset) is compiled only under MT_BUILD. Consequently, a failed sync leaves g_isLoading true while the legacy globals remain allocated, so the malformed legacy RESTORE described by this change bypasses this condition and reaches the same null-name dereference. Handle LOADING_FAILED and reset the flag independently of MT_BUILD.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, confirmed. On 2.10 the LOADING_FAILED branch only exists under MT_BUILD, which is off by default, so a failed load left g_isLoading set and this check was bypassed. Fixed in 0968786: the failed-load branch now always resets g_isLoading, and only the thread-pool drain stays under MT_BUILD. Verified on a default (non-MT) 2.10 build: the new test crashes the server without this change and passes with it. The 8.x branches already handle LOADING_FAILED in every build.
| from includes import * | ||
| from common import * | ||
| from RLTest import Env | ||
| from test_config import _grep_file_count |
There was a problem hiding this comment.
Define the imported log-count helper
tests/pytests/test_config.py does not define _grep_file_count, so importing this test module raises ImportError during RLTest collection before either test can run. Add the helper to the imported module or define it locally instead of importing a nonexistent symbol.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0968786: 2.10's test_config.py doesn't have this helper, so it's now defined in the test file.
The LOADING_FAILED branch of Indexes_LoadingEvent was compiled only under MT_BUILD, which is off by default. In a default build a failed load left g_isLoading set, so the legacy-spec refusal keyed on it was bypassed and a truncated legacy RESTORE still crashed. Only the thread-pool drain needs MT_BUILD. Also define the log-count helper in the test instead of importing it from test_config, which does not have it on this branch. 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.10 #11621 +/- ##
==========================================
- Coverage 89.55% 89.53% -0.02%
==========================================
Files 212 212
Lines 36712 36712
==========================================
- Hits 32877 32871 -6
- Misses 3835 3841 +6
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:
|
|



Backport of #11619 to
2.10.Merge commit:
b1b6903a1cc5b314fc64329f1434ff8f09710fddDescribe the changes in the pull request
ft_index0RESTOREoutside an RDB load, but it infers "outside a load" from the legacy-spec registry and theUPGRADE_INDEXrules being NULL. A failed load (LOADING_FAILED) leaves both allocated. So on a server that hasn't completed a load since startup, for example a replica whose first full sync failed and was then promoted, a truncated legacy payload still gets past the guard and crashes the server.g_isLoading).RESTOREof a legacy index spec now returns an error after a failed load too, instead of crashing the server.Which additional issues this PR fixes
Main objects this PR modified
IndexSpec_LegacyRdbLoad: the refusal now also checks loading state.test_legacy_module_types.py: new test that fails a full sync against a fake master, promotes the replica and restores a truncated legacy spec. Without the fix it crashes the server.Mark if applicable
Release Notes
🤖 Generated with Claude Code