Repository navigation
Deleted rows stay deleted after a restart - #143
Conversation
PR SummaryMedium Risk Overview DELETE + durability: Each delete now persists a Flush replay: On startup, Wiring: Integration tests cover Reviewed by Cursor Bugbot for commit 23980c0. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 23980c0. Configure here.
| } | ||
| } | ||
|
|
||
| self.replay_deletes_through(cursor).await?; |
There was a problem hiding this comment.
Markers dropped before replay completes
High Severity
A restart reflush writes deleted rows back, then truncate_before drops the DeleteMarker from wal_meta as soon as those WAL entries are gone. The matching replay_deletes_through runs only after that truncate. If replay fails, or the process dies in between, the durable marker is already gone and the restored rows stay. On restart flushed_margin_start returns the chunk end because sizes is empty, so this drop happens on the first reflush.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 23980c0. Configure here.
d51dd92 to
f17b2c0
Compare
23980c0 to
ae78d75
Compare
ae78d75 to
a7f0614
Compare
A restarted node flushes the WAL entries kept behind its last flush again, which put back rows a DELETE had removed. Each row delete now keeps a marker of how far the WAL was flushed; a restart replays the markers kept from before the WAL opened, at that point in the WAL, and drops them once the WAL is truncated past it.




Rows a DELETE removed no longer come back when a node restarts.
Bug
Since #132, DELETE removes rows from chDB. A restarted node flushes the WAL entries it kept behind its last flush again; they are kept on purpose, for chDB parts the OS had not written back. Those entries put the deleted rows back. Found by the n3 e2e of the stack: rows every pod had confirmed deleted reappeared after pod 1 restarted.
Fix
wal_meta: the table, the predicate, and how far the WAL was flushed when the delete ran (DeleteMarker,WalPort::record_delete).docs/user-guide/basic-operations.mddescribed DELETE as tombstones. It now describes row deletes, the restart replay, and the gap below.Not fixed
Only restarts are covered, as agreed. In a cluster, a write that reaches a replica after the replica applied the DELETE (replication queue, hinted handoff) is still not removed. A DELETE that times out waiting for the restart replay (15 s) can also miss rows the replay puts back afterwards.
Tests
deleted_rows_stay_deleted_after_a_restart_reflushes_the_wal, compat with chDB. The WAL is closed and reopened (TestContext::reopen_wal). Before the fix it returned[1.0, 2.0](expected[2.0]).a_row_written_after_a_delete_survives_the_restart_reflush: before the fix[1.0, 2.0, 3.0]. With the replay but without stopping chunks at markers,[2.0]: the later row was lost.delete_markers_outlive_a_reopen_until_truncated_past, RocksDB unit test: markers survive a reopen, are dropped only once truncation passes them, and ones recorded since the open are not replayed.