Repository navigation
Conversation
Selected masks and lookup hits alone miss historical rows restored by concurrent index changes. Check intervening COMPACT and OVERWRITE snapshots in the same partition and bucket, including CAS retries. Recover overwrite compaction using current deletion vectors and surviving original L0 inputs so later writes retain their lookup changelogs. Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
JeonDaehong
left a comment
There was a problem hiding this comment.
Ran the commit tests on e9eeda8 together with pk_compact_test deletion_vectors and write_compact_overwrite_recovery_test. All pass, and skipping check_dv_compaction_history fails compact_cas_retry_rechecks_same_bucket_history, selected_dv_container_repacking_in_an_overwrite_invalidates_compaction and overwrite_recovery_after_cas_loss_refreshes_dv_and_preserves_append_changelog, so the new path is well covered. Two questions inline.
| } else { | ||
| self.snapshot_manager.get_snapshot(id).await? | ||
| }; | ||
| if snapshot.commit_user() != self.commit_user |
There was a problem hiding this comment.
Dropping the commit_user condition here keeps all of those tests passing, so the skip isn't exercised by any of them. Which case is it for? Two compactions that share a commit user (for example tasks of one job) on the same bucket would not be checked against each other, so a test that pins down why it's safe would help.
| let after = snapshot.index_manifest(); | ||
| if changes_data | ||
| || (before != after | ||
| && read_indexes(before).await? != read_indexes(after).await?) |
There was a problem hiding this comment.
before is the previous snapshot's index manifest, which the previous iteration may already have read as after. Keeping the last decoded map would avoid reading it twice when several foreign COMPACT or OVERWRITE snapshots follow each other.
JingsongLi
left a comment
There was a problem hiding this comment.
The stale DV conflict checks and overwrite recovery have end-to-end value. The six targeted retry tests and 129 compaction and recovery integration tests passed on the PR head. An additional assertion on the injected CAS race found an abandoned prepared output.
| ) | ||
| .await?; | ||
| if let Some((captured, latest)) = dv_snapshots { | ||
| self.check_dv_compaction_history(captured, latest, entries) |
There was a problem hiding this comment.
[P2] Reclaim automatic compaction outputs after a definite rejection
In overwrite_recovery_after_cas_loss_refreshes_dv_and_preserves_append_changelog, the publisher definitively returns Ok(false) for the first automatic COMPACT. The retried commit then hits this history rejection, and auto maintenance drops its prepared output paths. I recorded the ADD file from that rejected snapshot's delta manifest. After recovery succeeded, the file was absent from the active manifest and still present in bucket-0.
Repeated races can accumulate one set of abandoned data and sidecar files per failed attempt until orphan cleanup. Keep ownership of automatic outputs and reclaim them on definite nonpublication. Preserve them when publication has an unknown outcome.
Keep automatic compaction outputs through publication retries and reclaim them after confirmed nonpublication. Verify file-store rejections before cleanup so a replayed conditional write cannot delete published outputs. Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
JingsongLi
left a comment
There was a problem hiding this comment.
The stale-DV conflict checks and recovery have end-to-end value. The previous definite-rejection output leak is addressed on the file-store path. Locally, 128 compaction/recovery integration tests plus seven DV retry and three automatic-compaction tests passed. A REST commit probe found the data-loss path below.
| // write. Only a different snapshot can prove that cleanup is safe. | ||
| // REST mutations are not replayed and return a definite rejection. | ||
| let publication = match publication { | ||
| Ok(false) if automatic_outputs_published.is_some() && self.table.rest_env.is_none() => { |
There was a problem hiding this comment.
[P1] Keep automatic compaction outputs after an ambiguous REST response
RESTApi::commit_snapshot currently maps a successful HTTP response without a boolean success to Ok(false). This branch treats REST false as proof of rejection. If the catalog published the snapshot before returning that response, the retry can find the published duplicate while automatic_outputs_published and publication_uncertain both remain false. Cleanup then deletes files referenced by the published snapshot.
I reproduced this through the REST catalog with two appends to an ordinary append table. The server durably published COMPACT snapshot 3 and returned HTTP 204. The second writer call returned Ok(()), but the snapshot's only data file had already been removed. Please map an absent or invalid success to an ambiguous outcome, and retain this attempt's outputs when duplicate detection confirms that it published them.
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Require an explicit boolean success in snapshot commit responses. When a retry finds the same automatic compaction attempt, keep its published files even if the original response reported rejection. Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
JingsongLi
left a comment
There was a problem hiding this comment.
The same-bucket DV conflict checks and overwrite recovery have end-to-end value. All 554 checked-in compaction, commit and REST tests passed on f94218b1, this PR merged locally with current main (c4045ac5). Two extra REST tests still found published compaction files being removed.
| Ok(outcome) | ||
| } | ||
| .await; | ||
| if !automatic_outputs_published && !publication_uncertain { |
There was a problem hiding this comment.
[P1] Confirm this attempt is unpublished before deleting compaction files
The new REST test covers a server that publishes COMPACT and then returns {"success":false}. I kept that response and set commit.max-retries=0. The server published snapshot 3, but the retry limit is checked before duplicate detection can mark the private outputs as published. Cleanup deleted the Parquet file. filter_and_commit_with_identifier then returned success for the same commit, and a table scan failed with NotFound on that file.
With a primary-key DV table and retries enabled, I compacted a 1,000-row run, updated key 42, and used the same REST response for the automatic compaction. The writer returned success. The published index manifest referenced a missing DV container because try_commit_once deleted it on the false response before duplicate detection.
Please verify that the stored snapshot belongs to a different attempt before deleting either data or attempt-generated DV files. Do that check before exhausting the retry budget, and retain the files if publication remains uncertain.
REST can report rejection after publishing an automatic compaction. Verify the catalog snapshot before deleting prepared data or generated deletion vectors, even when the retry budget is exhausted. Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Pass the shared PK index maintenance round alongside the overwrite L0 scope during compaction execution, and update the automatic compaction test to the combined interface. Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
JingsongLi
left a comment
There was a problem hiding this comment.
I reran 296 PK compaction, overwrite-recovery and REST integration tests plus 223 core commit tests. The previously reported REST cases now retain the published data and DV files, including the false-response case with zero retries. A separate end-to-end recovery probe reproduced a lookup changelog issue.
| } | ||
| } | ||
| } | ||
| if files.is_empty() { |
There was a problem hiding this comment.
[P1] Preserve lookup suppression when a normal append compacts first. I published an OVERWRITE containing key 1 on a PK DV table with merge-on-read enabled, then interrupted it before auto compaction. A reader bootstrapping at that durable snapshot could already see key 1. A subsequent normal APPEND of key 2 compacted both L0 inputs. Retrying the overwrite recovered successfully, but a changelog scan from the overwrite snapshot returned +I for both keys, replaying the already-visible key 1. The existing recovery tests leave the later append pending with write-only=true. Please cover the ordinary writer too and preserve the overwrite input's suppression through the competing compaction.
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Purpose
Existing input-mask and lookup-hit checks miss historical rows restored by an index-only overwrite, allowing stale PK DV compaction to commit. Overwrite recovery also skipped surviving inputs after partial replacement, leaking suppressed changelogs.
Brief change log
Tests
561 focused tests passed. CI-pinned formatting and workspace Clippy with vortex passed.
API and Format
No public API or storage format changes.
Documentation
Updated compaction conflict and recovery behavior.