Skip to content

fix: TRUNCATE keeps rows written earlier in the same batch - #90

Merged
hasyimibhar merged 1 commit into
mainfrom
fix/truncate
Oct 5, 2026
Merged

hasyimibhar merged 1 commit into
mainfrom
fix/truncate

Conversation

@hasyimibhar

@hasyimibhar hasyimibhar commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes truncate_removes_rows_not_yet_materialized, plus a TOAST stall the random DST found while I was verifying this fix.

  • TRUNCATE. expand_truncates turned a TRUNCATE into deletes of the keys in the FileIndex, meaning the rows already materialized. Rows written earlier in the same fold step aren't in the FileIndex yet, so they survived. The TRUNCATE now also drops the events before it in the step. Earlier steps of the same unit are covered already, because preparing a step updates the FileIndex.
  • TOAST on a key change's delete half. The delete half of a split key change kept the update's unchanged TOAST columns, so TOAST resolution ran for a delete. Usually that worked by luck. But when a crash between claim and ack replays the transaction, the replayed delete comes after the first copy has already moved the row. Resolution then failed for good ("TOAST resolution failed: PK … is not in any indexed data file") and the table stalled. The split now leaves the delete with no unchanged columns, and resolution skips deletes. Either change alone fixes the stall.

`expand_truncates` turned a TRUNCATE into deletes of the keys in the
FileIndex — the rows already materialized — but rows written earlier in
the same fold step aren't there yet, so they survived it. The TRUNCATE
now also drops the events before it in the step; earlier steps of the
unit are in the FileIndex already.

Also: the delete half of a split key change carried the update's
unchanged TOAST columns, so TOAST resolution ran for a delete. Replayed
after a crash between claim and ack, that delete comes after the first
copy moved the row, and resolution failed for good ("TOAST resolution
failed: PK … is not in any indexed data file"). The split now leaves the
delete none, and resolution skips deletes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hasyimibhar
hasyimibhar merged commit 3ba4f4a into main Oct 5, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant