Skip to content

fix: clear stale overflow-read state and return corrupt on mismatch#6324

Open
ongyimeng wants to merge 2 commits intotursodatabase:mainfrom
ongyimeng:investigate-btree-overflow-read-panic
Open

fix: clear stale overflow-read state and return corrupt on mismatch#6324
ongyimeng wants to merge 2 commits intotursodatabase:mainfrom
ongyimeng:investigate-btree-overflow-read-panic

Conversation

@ongyimeng
Copy link
Copy Markdown
Contributor

Description

Fix an intermittent overflow-read panic in the sync parallel writes repro.

Root cause:
process_overflow_read() could resume using stale read_overflow_state after the cursor context changed. In that case, overflow reading could continue against the wrong record state, which could lead to a panic.

What changed:

  • Clear stale read_overflow_state on additional cursor reposition paths
  • Return Corrupt instead of panicking when an overflow-chain mismatch is detected

Validation:
Because this issue is intermittent, I validated it by running the repro command in a loop.

  • Fix branch: 90 runs, no overflow panic, 1 known unrelated Busy failure
  • Main branch: latest observed overflow panic repro was on run 4

Motivation and context

#6108

Description of AI Usage

Used AI to help investigate the panic, reason about the stale overflow-read state path, and draft the fix and validation approach. All code changes and conclusions were reviewed and validated with repeated repro runs.

@ongyimeng ongyimeng force-pushed the investigate-btree-overflow-read-panic branch from beb28e9 to fe10f98 Compare April 8, 2026 03:50
@ongyimeng ongyimeng marked this pull request as ready for review April 8, 2026 04:19
@ongyimeng ongyimeng requested a review from pereman2 as a code owner April 8, 2026 04:19
Copy link
Copy Markdown

@turso-bot turso-bot bot left a comment

Choose a reason for hiding this comment

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

Please review @pereman2

@ongyimeng
Copy link
Copy Markdown
Contributor Author

@LeMikaelF tagging you here as well since you replied on the original issue

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.

1 participant