Repository navigation
fix(backup): preserve hidden commitTS in rewritten tombstones - #26998
mergify[bot] merged 7 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
[P1] Close the reader-side compatibility boundary for already-generated malformed Backup tombstones
The producer rewrite in this PR is sound for newly generated backups, but the exact artifacts created by affected releases remain on the original crash path. For a non-CN tombstone with meta_columns=3, max_seq=2, and a trailing physical TS column, ResolveSpecialColumnLayout reports no hidden commitTS. The column reader then synthesizes a const-null TS vector with logical row count N but zero fixed backing elements. ReadDeletes validates only the abort vector, so both IsRowDeletedByLocation and EvalDeleteMaskFromDNCreatedTombstones still index tss[i] using the non-empty rowid length and panic.
That is not only a migration limitation: a backup may be the sole recovery copy, and it also leaves the explicit #26991 contract (malformed metadata returns a bounded error, never an index panic) unmet. Please add one shared commitTS validation/compatibility boundary before either consumer indexes it. For the narrowly identifiable malformed Backup signature, recover the physical trailing TS column when it is unambiguous; for ambiguous/corrupt layouts, return an explicit bounded error rather than weakening special-column detection globally. Add deterministic coverage through both consumer paths, including the timestamp-valued user-PK control. The producer-side canonical writer change should stay as-is.
|
Thanks. I rechecked the release boundary and history before deciding the scope here:
Given that 4.2 has not shipped, I do not think compatibility recovery for artifacts generated by affected 4.2 development builds should block this producer fix. This PR closes the format invariant before the first 4.2 release and prevents all newly generated filesystem/S3 backups from creating the malformed layout. I agree that two reader-side questions remain useful, but they are a separate compatibility/hardening boundary:
Those should be handled in a focused follow-up once the cross-version recovery policy is confirmed, rather than coupling reader reinterpretation of malformed on-disk metadata into this producer correction. Accordingly, I propose keeping the producer writer change in this PR as-is and treating the reader-side compatibility/error-hardening portion of #26991 as follow-up scope. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
[P1] Reader compatibility/safety remains a blocking part of #26991
I re-reviewed the producer fix and the release-history argument. The canonical rewrite in this PR is correct for newly generated backups, and its focused tests pass. However, the release boundary does not make the remaining reader failure safe:
- v4.1.4 already ships the same generic Backup writer at this path. It can persist the exact
[0,1,2],meta_columns=3,max_seq=2, trailing-TS artifact. The v4.1 reader accepting that trailing TS only masks the malformed metadata; the durable backup artifact remains malformed. - On this PR head,
ResolveSpecialColumnLayoutrejects that layout,ReadOneBlocksynthesizes a const-null commitTS vector with logical length N but no fixed backing values, andReadDeletesvalidates only abort. BothIsRowDeletedByLocationandEvalDeleteMaskFromDNCreatedTombstonesstill indextss[i]using the non-empty rowid length and panic. - Therefore a v4.1-generated recovery copy can enter this failure after restoration with the 4.2 reader. Even if direct cross-version restore is ultimately declared unsupported, malformed metadata still violates #26991 explicit safety contract: return a bounded corruption/compatibility error rather than an index panic.
Please add one shared commitTS validation boundary before both consumers index it. Recover the narrow non-CN Backup signature only when the trailing TS is unambiguous; otherwise return a bounded explicit error. Add deterministic tests through both reader paths, including the timestamp-valued PK counterexample. The producer/canonical-writer changes in this PR should remain as they are.
|
Thanks for the second review. I reproduced the boundary directly and agree that the reader-side part is a P1 blocker, so I updated this PR in commit The apparent v4.1.4 counterexample is now explained: v4.1.4 -> v4.1.4 Backup/restore succeeds because that reader still infers the trailing physical TS column by position. The durable artifact nevertheless has the generic-writer metadata ( The update adds:
The review also exposed a related producer issue: Validation completed on the updated diff:
The producer canonical-writer fix remains intact, and the PR description has been updated to document both the same-version behavior and the cross-version compatibility boundary. |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The current head canonicalizes rewritten tombstones with hidden commitTS and safely reloads the exact legacy layout. No independent blocking or non-blocking findings remain.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #26991 ## What this PR does / why we need it: This is the `4.2-dev` backport of #26998, adapted to the 4.2 tombstone reader and on-disk layout. Backup rewrites appendable TN tombstones after filtering rows by the backup timestamp. The old rewrite path used a generic block writer, which assigned dense seqnums to the physical `[rowid, pk, commitTS]` batch. As a result, commitTS was persisted as ordinary seqnum `2` instead of hidden `SEQNUM_COMMITTS`. The v4.1 reader inferred that trailing column by position, so a v4.1.4 backup restored by v4.1.4 still works. The stricter 4.2 reader treats commitTS as absent, synthesizes a const-null vector with no fixed backing values, and could panic, reject recovery, silently omit tombstones, or conservatively report false PK conflicts depending on the consumer. This PR closes both the producer and every identified reader boundary. For newly generated backups, the trim path now produces one canonical non-appendable TN tombstone layout: ```text physical columns: [rowid, pk, commitTS] seqnums: [0, 1, SEQNUM_COMMITTS] meta columns: 3 max seqnum: 1 ``` The producer implementation: - resolves commitTS, abort, and physical-rowid positions from source object metadata; - filters aborted rows and rows newer than the backup timestamp before rewriting; - drops the stale physical row address and the already-consumed abort column; - writes rewritten tombstones with explicit hidden-column seqnums; - materializes a valid N-row constant commitTS before `BlockWriter`, whose fixed-width metadata scan otherwise indexes beyond the one-value backing; - validates malformed source columns and releases rewritten batches on success and error paths without double-freeing shared `objData` references. For existing malformed Backup artifacts, the reader implementation: - recognizes only the exact non-CN, non-appendable three-column signature (`meta_columns=3`, `max_seq=2`, `[Rowid, PK, TS]`, and no strict hidden commitTS); - reloads physical column `2` as commitTS while keeping a timestamp-valued user PK distinct; - validates commitTS at shared reader boundaries and returns bounded errors for missing, null, wrong-type, length-mismatched, or short-backing vectors; - preserves valid non-null constant-vector broadcast semantics in point lookup, block-mask evaluation, stats readers, local tombstone application, PK-change checks, and TAE persisted scans; - routes `persistedNode.Scan` and `CollectObjectTombstoneInRange` through the compatibility mapping, while preserving the established two-column CN tombstone `CreatedAt` semantics; - releases the first cache lease and temporary vector wrappers before compatibility reload, then transfers or releases the final copy/zero-copy ownership exactly once; - propagates an initial merge-stats iterator read error instead of silently returning an undercount, while releasing previously admitted iterators. `4.2-dev` predates the shared `objectio.SpecialColumnLayout` and still uses a reader layout without abort (`[rowid, commitTS]`, or `[rowid, pk, commitTS]` when PK is requested). This backport preserves that 4.2 protocol and keeps an equivalent special-column resolver local to Backup instead of pulling later appendable-object/abort reader changes into the maintenance branch. The fix is fileservice-backend independent, so DISK, DISK-V2, and S3 Backup rewrites use the same corrected metadata and reader paths. Validation: - deterministic old generic-writer artifact consumed through point lookup, block mask, Backup datasource, varlen-PK search, TAE copy Scan, zero-copy Scan, and range collection; - CN-created two-column control proving Scan and range collection still derive commitTS from object `CreatedAt`; - timestamp-valued user-PK counterexample proving PK and trailing commitTS remain distinct; - exact compatibility-reload failure injection and non-legacy error paths with cache-lease accounting; - source layouts with commitTS only and physical rowid before/after commitTS; - abort metadata compatibility at the Backup rewrite boundary; - future, aborted, partially retained, and fully filtered row sets; - malformed/missing/short/null commitTS returns a bounded error; - persisted and producer-side N-row constant commitTS broadcast coverage, including `canonicalize -> WriteBatch -> Sync -> ReadDeletes`; - merge-stats initial reader-error propagation; - actual 4.2 checkpoint rewrite followed by metadata inspection and `IsRowDeletedByLocation` verification; - full tests for `pkg/objectio/ioutil`, `pkg/vm/engine/tae/logtail`, `pkg/vm/engine/tae/tables`, `pkg/vm/engine/disttae`, and `pkg/vm/engine/disttae/logtailreplay`; - affected-package `go list`, build, vet, and scoped `golangci-lint` (0 issues). --------- Co-authored-by: XuPeng-SH <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head 35f62d0. The prior reader-side blocker is closed: the compatibility path is restricted to the exact legacy Backup signature, reload ownership releases the first cache lease before retry and all error paths are bounded, timestamp-valued PK remains distinct, and every commitTS consumer now preserves constant-vector broadcast semantics. The producer writes the canonical [rowid, pk, hidden commitTS] layout and the checkpoint rewrite regression verifies the persisted metadata plus real delete lookup. Focused regressions passed 10x; full objectio/ioutil, tae/logtail, disttae, and logtailreplay tests, plus affected-package build/vet, all passed. No blocking findings.
Merge Queue Status
This pull request spent 1 hour 27 minutes 48 seconds in the queue, including 48 minutes 13 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #26991
What this PR does / why we need it:
Backup rewrites appendable TN tombstones after filtering rows by the backup timestamp. The old rewrite path used a generic block writer, which assigned dense seqnums to the physical
[rowid, pk, commitTS]batch. As a result, commitTS was persisted as ordinary seqnum2instead of hiddenSEQNUM_COMMITTS.The v4.1 reader inferred that trailing column by position, so a v4.1.4 backup restored by v4.1.4 still works. A current strict special-column reader, however, treats commitTS as absent, synthesizes a const-null vector with no fixed backing values, and could panic while evaluating a v4.1-generated recovery artifact.
This PR closes both sides of that boundary.
For newly generated backups, the trim path now produces one canonical non-appendable TN tombstone layout:
The producer implementation:
objDatareferences.For existing v4.1-style artifacts, the reader implementation:
meta_columns=3,max_seq=2,[Rowid, PK, TS], and no resolved hidden commitTS);2as commitTS while keeping a timestamp-valued user PK distinct;ReadDeletesboundary and returns bounded errors for missing, null, wrong-type, length-mismatched, or short-backing vectors;The fix is fileservice-backend independent, so DISK, DISK-V2, and S3 Backup rewrites use the same corrected metadata and reader paths.
Validation:
IsRowDeletedByLocationverification;pkg/objectio/ioutil,pkg/vm/engine/tae/logtail, andpkg/vm/engine/disttae/...tests, plus build/vet for affected packages.