Skip to content

[MOD-15685] Fix crash when a legacy index spec is restored after a failed replication sync - #11619

Merged
kei-nan merged 1 commit into
masterfrom
jk-legacy-restore-after-failed-load
Sep 29, 2026
Merged

kei-nan merged 1 commit into
masterfrom
jk-legacy-restore-after-failed-load

Conversation

@kei-nan

@kei-nan kei-nan commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

  1. Current: [MOD-15685] Fix crash when a legacy index spec is restored on a running server #10872 refuses a legacy ft_index0 RESTORE outside an RDB load, but it infers "outside a load" from the legacy-spec registry and the UPGRADE_INDEX rules 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.
  2. Change: also refuse when no load is in progress (g_isLoading).
  3. Outcome: RESTORE of a legacy index spec now returns an error after a failed load too, instead of crashing the server.

Which additional issues this PR fixes

  1. MOD-15685
  2. Follow-up to [MOD-15685] Fix crash when a legacy index spec is restored on a running server #10872. Addresses the Codex review findings on its backports [8.4] [MOD-15685] Fix crash when a legacy index spec is restored on a running server #11615 and [8.10] [MOD-15685] Fix crash when a legacy index spec is restored on a running server #11612.

Main objects this PR modified

  1. IndexSpec_LegacyRdbLoad: the refusal now also checks loading state.
  2. 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

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

🤖 Generated with Claude Code

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T12:53:15.932087Z 05498b3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.53%. Comparing base (a26c6a5) to head (05498b3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11619      +/-   ##
==========================================
- Coverage   84.23%   83.53%   -0.71%     
==========================================
  Files         640      665      +25     
  Lines       85436    86529    +1093     
  Branches    39264    40356    +1092     
==========================================
+ Hits        71969    72280     +311     
- Misses      13101    13875     +774     
- Partials      366      374       +8     
Flag Coverage Δ
flow 84.62% <100.00%> (+0.01%) ⬆️
unit 58.97% <0.00%> (-0.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kei-nan
kei-nan added this pull request to the merge queue Sep 29, 2026
Merged via the queue into master with commit b1b6903 Sep 29, 2026
109 checks passed
@kei-nan
kei-nan deleted the jk-legacy-restore-after-failed-load branch September 29, 2026 14:36
@redisearch-backport-pull-request

redisearch-backport-pull-request Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Auto-backport summary

Target Status Backport PR
2.10 clean #11621
8.2 error no reproducible conflict; check action logs and retry (publication or infrastructure failure)
8.4 conflicts(2) #11627
8.6 conflicts(2) #11625
8.6-rse conflicts(2) #11626
8.8 conflicts(2) #11624
8.8-rse clean #11622
8.10 conflicts(2) #11623

(PR #11619, b1b6903a1 — generated by the auto-backport workflow.)

Workflow run · Retry unfinished targets with /backport <branches>.

eyalrund added a commit that referenced this pull request Sep 29, 2026
Resolve the conflict in test_legacy_module_types.py by keeping both the
legacy-loader tests from this branch and the failed-sync RESTORE test from
master (#11619).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
eyalrund added a commit that referenced this pull request Sep 29, 2026
…field-path-load

Pick up master (via #11605's branch) and resolve the conflict in
test_legacy_module_types.py by keeping both this branch's test and
master's failed-sync RESTORE test (#11619).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kei-nan

kei-nan commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

/backport 8.2

@redisearch-backport-pull-request

redisearch-backport-pull-request Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Auto-backport summary

Target Status Backport PR
8.2 clean #11638

(PR #11619, b1b6903a1 — generated by the auto-backport workflow.)

Workflow run · Retry unfinished targets with /backport <branches>.

kei-nan added a commit that referenced this pull request Sep 30, 2026
…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)
kei-nan added a commit that referenced this pull request Sep 30, 2026
…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)
kei-nan added a commit that referenced this pull request Sep 30, 2026
…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)
kei-nan added a commit that referenced this pull request Sep 30, 2026
…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)
kei-nan added a commit that referenced this pull request Oct 1, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants