Skip to content

Fix deferred FK mismatch on savepoint release#6362

Open
pedrocarlo wants to merge 2 commits intotursodatabase:mainfrom
pedrocarlo:codex/create-minimal-reproducer-and-implement-fix
Open

Fix deferred FK mismatch on savepoint release#6362
pedrocarlo wants to merge 2 commits intotursodatabase:mainfrom
pedrocarlo:codex/create-minimal-reproducer-and-implement-fix

Conversation

@pedrocarlo
Copy link
Copy Markdown
Collaborator

@pedrocarlo pedrocarlo commented Apr 10, 2026

Description

  • Pager: updated release_savepoint and rollback_to_newest_savepoint in core/storage/pager.rs to locate and remove the most-recent Statement savepoint via rposition and update parent offsets correctly, and only truncate the subjournal when appropriate.
  • FK generation: simplified parent-key UPDATE handling in core/translate/fkeys.rs by removing the NEW-key probe from emit_fk_parent_pk_change_counters and keeping NEW-key reconciliation in the REPLACE-specific path, avoiding over-decrements of the deferred-FK counter.
  • Tests: added a deterministic reproducer release_root_named_savepoint_checks_deferred_fk in tests/fuzz/savepoint.rs that asserts parity with SQLite for releasing a root named savepoint that triggers deferred FK failures.

Motivation and context

  • A differential fuzz seed revealed a parity failure with SQLite when releasing nested named savepoints that left statement-savepoints stacked beneath them, causing deferred foreign-key counters to be mishandled.
  • The intent is to ensure statement savepoint cleanup and deferred-FK bookkeeping match SQLite semantics so release/rollback behavior is consistent.

Description of AI Usage

Generated with codex

@pedrocarlo pedrocarlo force-pushed the codex/create-minimal-reproducer-and-implement-fix branch from fefe915 to ee25024 Compare April 10, 2026 20:38
@pedrocarlo pedrocarlo marked this pull request as ready for review April 10, 2026 21:10
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

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