Repository navigation
fix(tae): filter TN rewrites by row commit time - #26163
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? |
c901a83 to
875588b
Compare
8b5c2df to
35b5180
Compare
|
这轮 unhappy-path review 有 1 个高置信 blocker:
这不是理论路径:你新加的 建议修法:不要只根据 replacement object 当前的 因为这是你的 PR,GitHub 不允许我直接 |
35b5180 to
2ec7844
Compare
|
已合理采纳 blocker comment,并补了能够在修复前稳定失败的真实组合测试。 确认的问题:direct CN-created object 被 TN mixed merge 后会失去 修复没有简单传播
新增测试使用真实 CN object + TN flush + mixed multi-output merge,修复前并发 CN case 稳定返回 nil;修复后验证:旧 TN PK 不误报、并发 CN PK 返回 WW、WAL restart 后标记仍在、第二次 merge 继续传播且旧 CN PK 不误报。 验证:边界矩阵 |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The prior rolling-upgrade blocker is fixed: producers advertise the append-only lineage contract at the shared merge boundary, while TN validates authoritative catalog lineage before any catalog mutation and rejects legacy CN results. Earlier CN-merge metadata/commit-TS, legacy-null compatibility, and per-row output-lineage blockers remain fixed; the stale blanket-marking concern is withdrawn. No blocking or non-blocking defect remains. Protobuf compilation and diff checks passed; CGo tests could not run because libmo.dylib is absent.
|
Latest-head re-review on What I specifically rechecked this round:
I also reran focused regressions covering:
On the current head, I did not find a new high-confidence correctness / robustness / unhappy-path blocker. LGTM on this latest head from my side. |
|
Latest-head correction: after cross-checking the new lineage fence against mixed-version behavior and the row-level incremental-dedup path, I do see two production-correctness blockers on the current head.
So I would move this latest head back to blocked on correctness. |
|
Latest re-review on the same head
So my current latest-head conclusion is: still blocked on one deterministic same-version correctness issue; no new steady-state performance hotspot found in this pass. |
LeftHandCold
left a comment
There was a problem hiding this comment.
Requesting changes on exact head 24c25f23 for two reachable data-correctness blockers.
- The lineage-version fence only closes old-CN -> new-TN. MatrixOne Operator reconciles DNSet and CNSet independently, so new-CN -> old-TN is reachable; the old TN ignores field 11 and strips
CNOriginthroughSetObjectStats, silently committing an unlineaged replacement. - A patched CN intentionally preserves null commit TS for legacy TN rows in a mixed
CNOriginoutput, while incremental dedup treats any matching null-TS row as a duplicate. I reproduced the terminal deterministically: a row committed before txn start was physically rewritten afterward andFreezereturnedDuplicate entryinstead of ignoring it.
The prior same-version CN metadata/commit-TS paths and old-CN/new-TN pre-mutation rejection are fixed. I rechecked object/wire compatibility, per-output lineage across generations, restart behavior, hidden-column detection, validation ordering, vector ownership, and error cleanup; no third blocker found. Clean-head affected-package tests, focused DB regressions, focused race, vet, and diff-check pass, and the current GitHub required CI is green.
|
Reasonably adopted both latest blockers in
Performance/risk: no new DML hot-path I/O or allocation. Dedup adds one policy/null check only after an exact PK match. CN merge adds two small control-plane RPCs around a storage-heavy, low-frequency merge and deliberately does not cache rollout state. Validation on final head:
I also re-read every prior issue/review thread: the earlier CN metadata, legacy hidden-column, per-output/per-row lineage, restart, and old-CN -> new-TN blockers remain covered on this head. |
|
One point I am still confident about on the latest head: there is one same-version, steady-state correctness blocker left in the The problematic combination is:
So an old TN row that should be skipped by Separately: the earlier |
|
Rechecked this latest comment against exact head The exact-PK paths no longer treat a valid legacy null commit TS as an unconditional duplicate:
The DB regression is also the exact mixed-object terminal, not merely a shape test:
I reran the fixed/varlen policy matrix, malformed-vector boundary, and this real mixed-object DB regression at The rollout direction mentioned separately is also already closed on this head by the TN-advertised protocol-v5 pre/post capability checks; it is independent of this same-version conclusion. |
|
You were right to push on “latest”. I re-reviewed the actual current head On this current head, the two latest concerns I raised look closed:
I also reran the focused new tests and the full affected package set on this exact head ( |
|
One more latest-head note after reading the full current head The current fix is still probe-only, not bound to the apply contract itself:
That leaves a TOCTOU window during rollout: if the probed TN is replaced/rolled back after the second probe but before the write is actually applied, an older TN can still accept the merge. The transport path itself also documents that the TN address may need refresh when sending ( So my latest read is:
|
aptend
left a comment
There was a problem hiding this comment.
Blocking review
[P1] Bind the TN lineage capability to the actual OpCommitMerge apply.
The two capability probes in handleCNMerge are separate from the write they authorize. After the second probe and before txnWrite is applied, the selected TN can be replaced or rolled back. The request itself still uses the legacy OpCommitMerge contract and carries no receiver-enforced minimum protocol version. An old TN therefore accepts it, ignores the unknown lineage_version field, and reconstructs output catalog stats through the old SetObjectStats path, which drops the reserved-byte CNOrigin flag. The replacement is then indistinguishable from a pure TN rewrite and can be skipped by CheckIncremental, reintroducing a duplicate false negative.
Please make compatibility part of the apply contract itself—for example, a v5-only command/opcode, transport-level minimum version, or an epoch/capability token atomically validated by the receiver. Add a deterministic regression that swaps the target to an old TN between the final probe and apply, and verifies both no catalog mutation and cleanup of generated files.
The same-version mixed-lineage, legacy-null commit-TS, per-output propagation, and old-CN -> new-TN paths otherwise look closed on head 382b258470738e1f98c21094bdcd35b7667f5787. Focused race tests, full affected-package tests, and git diff --check passed locally. The failed Compose job is an unrelated Docker Hub image-pull timeout.
|
Deep review on exact head The newest aptend review is valid, and the current CI exposes a stronger same-version failure in the same design:
A minimal systemic closure is to make the apply operation itself versioned:
Please add integration coverage for same-version standalone success, new-CN -> old-TN V2 rejection, target replacement between generation and apply, zero catalog mutation, and generated-file cleanup after a definitive compatibility rejection. The helper-only ctl tests currently miss all of these terminals. The core lineage/dedup path otherwise looks sound in this pass: per-output/per-row propagation, legacy null commit TS, strict/incremental behavior, second-generation rewrite, vector ownership, and pre-mutation old-CN rejection all passed fresh affected-package tests, focused race, and DB regressions. The Compose failure is unrelated (Docker Hub image metadata timeout). |
LeftHandCold
left a comment
There was a problem hiding this comment.
Requesting changes on exact head 382b258470 for one reachable data-correctness blocker.
The two GetProtocolVersion probes are not the apply-time fence. After the second probe, rpc.sender.doSend retries ErrNoAvailableBackend, ErrBackendCannotConnect, and ErrBackendClosed against the same TN address for up to 30 seconds. During a normal TN replacement/rollback, the v5 TN can answer the probe, the first write can hit the closed backend, and the retry can reach the old TN after it comes up at that stable address. The request still uses legacy OpCommitMerge; the old receiver accepts it, ignores lineage_version, and reconstructs stats through old SetObjectStats, dropping CNOrigin. CheckIncremental can then skip the replacement and miss a real duplicate.
Please make the actual apply self-fencing, e.g. use a v5-only merge opcode that an old TN rejects. Keep the probe if desired for early failure and generated-file cleanup, and add a deterministic backend-replacement regression around the final probe/apply boundary.
The legacy-null row handling, old-CN -> new-TN validation, same-version mixed lineage, per-output propagation, restart persistence, and cleanup on the second-probe failure are otherwise closed. Affected-package tests, focused DB correctness regressions, vet, and git diff --check pass; I found no second blocker.
|
Updated original branch at fc5c1dc to adopt the latest P1 without retaining the probe workaround. Key outcome: compatibility is enforced atomically by OpCommitMergeV2 at TN apply. Old TNs fail before mutation; current TNs accept V1/V2; standalone no longer needs TN QueryAddress. MORPCVersion5 and both capability RPCs are removed. Definitive compatibility rejection cleans generated files; ambiguous transport failures preserve them. Production scope checked: automatic background merge currently runs TN-local; CN merge remains a real mo_ctl/task-executor operational path, but there is no current in-repo production creator for TaskCode_MergeObject. Operator CNSet/DNSet rollout is independent, so the short new-CN -> old-TN window is real even though the trigger is low frequency. This patch protects exactly that correctness boundary without adding global state, tables, caches, or hot-path I/O. Fresh validation: all 10 affected packages, 90s DB integration suite, focused race, affected build/vet, mo-service build, protobuf regeneration, and git diff --check. |
Resolve the db_test overlap with matrixorigin#26180 and harden incremental dedup to filter TN rewrites lazily by row commit timestamp, preserve the best-effort legacy fallback, and release result vectors on error.
|
Updated the existing branch to latest The deep review changed the implementation direction from a blanket TN-object skip to lazy row-time filtering:
Intentional boundary for reviewers: a TN rewrite containing CN-created rows can inherit null row timestamps. Making Local final evidence: related package tests PASS, focused |
|
@LeftHandCold @aptend @gouhongshen please help to review |
jiangxinmeng1
left a comment
There was a problem hiding this comment.
I found one blocker in the current head:
[P1] Release the LoadColumns2 result after reading commit timestamps
loadPersistedCommitTS discards the release callback returned by
ioutil.LoadColumns2:
vectors, _, err := ioutil.LoadColumns2(...)
With needCopy=false, the returned vectors reference IOVector.CachedData; calling
containers.Vector.Close() does not release that cached-data reference.
Consequently, every exact-PK candidate block can leak file-service cache data.
This PR expands the loader from appendable objects to incremental dedup over TN-
rewritten non-appendable objects, making the leak reachable repeatedly in the
normal precommit path and potentially causing unbounded memory growth.
Please retain the callback and invoke it when commitTSLoader.close() runs,
including validation-error paths, or load an owned copy and release the IOVector
immediately. The current mpool-based ownership tests do not detect this leak
because the retained memory belongs to the file-service cache allocation, not the
vector mpool.
Location: pkg/vm/engine/tae/tables/base.go:176 at head
acfca9c.
|
Thanks for calling out the ownership boundary. I double-checked the full lifecycle. The current call passes
The cloned commit-TS vector is closed by I adopted the actionable part of the review in commit
This does not add another callback or any production-path work, so there is no runtime performance change. Validation:
|
|
Deep review completed on exact head Verdict: I found no new code-level blocker on this head. I rechecked the full current diff and the relevant end-to-end contracts: hidden commit-TS detection, user The latest P1 review is based on I also traced the explicit missing/null commit-TS fallback through the production policy/configuration path. Incremental dedup's skip is a deliberate best-effort fallback under the default pessimistic PK-lock plus Independent validation completed successfully:
Code verdict for this exact head: no blocker found. CI completion and stale historical |
LeftHandCold
left a comment
There was a problem hiding this comment.
Requesting changes on exact head 29e7b0e040 for one reachable data-correctness regression.
CheckIncremental now skips an exact-PK match whenever the rewritten object has no row commit timestamp. The PR description treats the TN check as lock-backed best effort, which is valid for the default pessimistic path, but MatrixOne explicitly accepts txn.mode=Optimistic with incremental-dedup=true; that path has no LockOp/PrimaryKeysMayBeModified boundary and TN still selects DedupPolicy_CheckIncremental. CN merge produces exactly the problematic object shape: its writer uses only the table user seqnums, while the applied replacement is non-appendable and no longer CNCreated.
I reproduced this with the real object/catalog/Freeze path and compared the same test across commits: base d372ca22dd rejects the post-snapshot duplicate (DuplicateEntry), while head 29e7b0e040 returns nil and permits it. Please either keep missing commit-TS rows conservative outside a proven lock-backed mode, reject the optimistic+incremental configuration, or make CN merge outputs carry a trustworthy row timestamp.
The latest needCopy=true ownership path is correct: the source IOVector/CachedData is released before return, and the copied vector is closed by the block-scoped loader. Full affected-package UTs, focused race -count=3, build, vet, and diff checks pass. I found no second blocker.
| // upgrades. Strict policies stay conservative. This avoids | ||
| // adding lineage or an upgrade protocol to every merge. | ||
| if missingCommitTS(tsVec, row) { | ||
| if txn.GetDedupType().SkipTargetOldCommitted() { |
There was a problem hiding this comment.
[P1] Do not skip missing commit-TS rows for every CheckIncremental transaction. This assumes a pessimistic LockOp always provides the correctness boundary, but txn.mode=Optimistic plus explicit incremental-dedup=true is accepted by config; that mode has no LockOp, while HandleWrite still selects DedupPolicy_CheckIncremental. CN merge writes only user host.seqnums, so its replacement is non-appendable, CNCreated=false, and lacks this hidden column, making an exact post-snapshot duplicate reach this return nil.
I reproduced this on exact head through real object/catalog/Freeze code. With a transaction started first and a matching CN-merge-shaped object committed afterward, base d372ca22dd returns DuplicateEntry, but head 29e7b0e040 returns nil. Keep missing timestamps conservative unless lock/recheck protection is proven, reject optimistic+incremental at configuration time, or persist a trustworthy timestamp in CN merge output. The fixed-size branch below needs the same correction.
There was a problem hiding this comment.
Thanks for the concrete reproduction. The reproduced behavior is technically valid for the constructed configuration, but it is outside the supported production scope of this PR.
The Optimistic BVT/path has been deprecated. Current production uses the pessimistic transaction path, where incremental dedup is protected by the PK LockOp plus PrimaryKeysMayBeModified recheck contract. In addition, TN configuration already defaults incremental-dedup to false when txn.mode=Optimistic; the reproduction therefore requires explicitly enabling a non-default combination on a deprecated mode.
We should not add lineage/object-format/upgrade machinery, nor make every missing commit-TS row conservative, solely to support that deprecated combination. Either change would add complexity or cost to the supported production path and work against the deliberate best-effort scope of incremental dedup.
So I agree that the test demonstrates a formal hole in the still-accepted legacy configuration surface, but I do not consider it a production P1 or a blocker for this PR. Cleanup of the deprecated Optimistic configuration surface can be handled separately if needed.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The previous approval is no longer valid because the implementation changed after 24c25f2. The earlier lineage/rolling-upgrade and mixed-CNOrigin blockers were fixed in intermediate commits, then made obsolete when that design was removed. The reported CachedData leak is withdrawn: needCopy=true releases the source IOVector and the copied vector is closed correctly. One current P1 remains unresolved: optimistic mode with incremental dedup can skip a post-snapshot duplicate when commit-TS is missing. LeftHandCold already raised it on this exact head, so it is not duplicated below. I found no additional defects in the new review surface. The merge conflict resolution was test-only; upstream merge changes were excluded. git diff --check passed; focused tests could not start because cgo/libmo.dylib is absent.
What this fixes
CheckIncrementalselects committed objects in a timestamp window. For a TN flush or merge output, however,ObjectEntry.CreatedAtis the physical rewrite time, not the logical commit time of every row inside it. Old rows rewritten after a transaction snapshot could therefore be treated as new candidates and produce a false duplicate.Fixes #26162.
The original flaky symptom was exposed by
TestDelete3. Dedicated deterministic tests now cover both sides of the rewrite window: old rows must be ignored, while a row committed after the transaction snapshot must still cause a WW conflict even if TN flushes it before pre-prepare.Design
For a TN-created nonappendable candidate:
The commit-TS vector is block-scoped, loaded at most once, and released on success and error.
incrementalGetRowsByPKnow also closes and nils its result vector when an error occurs, so ownership transfers to the caller only on success.Direct CN-created objects retain the existing object-level conservative check because they do not carry TN row commit timestamps.
Explicit fallback boundary
Incremental dedup on TN is a best-effort fallback, not the primary correctness boundary for normal production DML. Pessimistic-RC primary/unique-key locks serialize same-key writers, and
LockOpcallsPrimaryKeysMayBeModifiedwhen the lock timestamp advances;LOAD DATAuses a table lock.Some legacy objects, and TN rewrites containing CN-created rows, have missing/null row commit timestamps:
CheckIncrementalskips an unverifiable row to avoid upgrade/rewrite false positives.CheckAllandFullSkipWorkspaceDedup) remain conservative and report it as a duplicate.This is deliberate. Making that rare incremental fallback independently exact would require CN-origin lineage, merge propagation, protobuf/opcode changes, and a rolling-upgrade protocol. This PR adds none of those steady-state costs or format changes.
Performance
Validation
TestDelete3plus all fix(tae): align late aobject visibility with parent txn #26180 appendable-object visibility/rollback tests.pkg/objectio,pkg/vm/engine/tae/tables,pkg/vm/engine/tae/txn/txnimpl, andpkg/vm/engine/tae/db/test.-race -count=10; all four packages pass full-race.go vet -mod=readonly -tags matrixone_test -unsafeptr=false ./pkg/...passes.git diff --checkpasses.