Skip to content

fix(tae): preserve incremental conflict-check coverage - #29748

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/29744-tae-conflict-checks
Oct 8, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/29744-tae-conflict-checks

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #29744

What this PR does / why we need it:

Two storage transactions replacing the same predecessor can both commit when a flush/merge transfers its deletion. A successful tombstone check advances the shared dedup watermark before the data check, leaving the latter an empty interval. The memory index also excludes the first candidate row, and its timestamp-to-row conversion excludes an entire append exactly at the inclusive lower timestamp. A point lookup can hide the resulting duplicate PK rows.

Move the watermark to each existing baseTable, keeping data and tombstone coverage independent in both PK and persisted-source checks. Convert the inclusive timestamp window using the endpoint before from, and include the lower row offset while retaining the exclusive upper bound, aborted-owner fallback, and ordinary WW conflict checks. No storage format, API, locks, workers, or parallel validation path is added.

Extend the existing competing-predecessor test with a deterministic flush/merge schedule. Require the second commit to fail, then verify the winning value and exactly one visible row before and after restart. Add focused coverage for independent stream checks/failure, timestamp equality including a multirow append, row zero, empty windows, aborted offsets, and conflicts outside the candidate window. Old-code overlays fail these boundary regressions.

The demonstrated schedule uses storage entry points. Normal CN pessimistic PK locking and snapshot refresh/retry protect this schedule; this PR does not claim a reproduced normal SQL corruption case.

Validation on Go 1.27.1/Linux amd64 with verified CPU CGo artifacts:

  • Normal and race tests for tae/index/indexwrapper, tae/tables, tae/txn/txnimpl, and tae/db/test, including the unchanged TestDelete4 and concurrent destination-key control.
  • Bounded focused race stress derived from measured test durations.
  • gofmt, go vet, repository-pinned molint, and configured golangci-lint v2.14.0 on the complete affected package closure: zero findings.
  • gpt-6.1-sol / xhigh design and overall review. GitHub CI remains pending.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head eca62ebce78cea0b3313e25999dc7b89d79b65ab against base 83d82b8ee0cd694e0c6a7146902d74ae4dfb415a. Code-level recommendation: approve; no blocking correctness or design findings.

The coverage watermark now belongs to the existing data/tombstone stream owner, and both PK and persisted-source consumers use that owner. The inclusive timestamp bounds consistently map to half-open row ranges. Aborted-owner fallback and ordinary write/write conflict checks remain intact; failed checks do not advance coverage. The change introduces bounded scalar state and constant-time boundary conversion, with no additional locks, workers, storage formats, or execution paths. Implementation, test, and documentation deltas were reviewed separately.

Validation: all four affected package suites passed normally and under the race detector; gofmt, vet, pinned molint, and configured golangci-lint passed. Focused race stress passed TestDelete4 46/46, competing-predecessor 100/100, and concurrent-destination-key 100/100.

Additional white-box QA used a real persisted replacement source (object writer + AddDataFiles), with a no-competitor control and a competing destination-key insertion committed and flushed before replacement prepare. Both cases pass on this head under race detection. Restoring only the old shared-watermark implementation makes the competitor case incorrectly commit successfully while the control still passes. This independently demonstrates that the persisted-source migration is necessary. This QA test was executed through an external overlay and is not included in the PR.

Non-blocking test recommendation: preserve that real-file/flushed-competitor regression by extending the existing TestReplacementChecksConcurrentDestinationKey with source/competitor variants, reusing its fixture rather than introducing another parallel fixture. No production change is requested.

There are no outstanding code-review comments or threads; the existing Qodo comment is an account/subscription notice. Shared build, arm64 SCA, and coverage checks are green; Ubuntu UT and proxy/pessimistic BVT checks were still running at the latest check. This review does not claim those pending checks passed. The demonstrated storage-entry schedule should not be presented as reproduced corruption through normal SQL pessimistic locking.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent senior-QA challenge of eca62ebce78cea0b3313e25999dc7b89d79b65ab against 83d82b8ee0cd694e0c6a7146902d74ae4dfb415a: no new blocking findings; code-level recommendation remains approve. No subagents were used.

New executed evidence:

  • Real authenticated MySQL frontend, two sessions establishing the old snapshot before either UPDATE commits, tested separately on the same CN and across CNs: final PK cardinality is exactly one and the incremented value is 2. SQL rollback, duplicate destination rejection, legal PK change, and multirow REPLACE also pass with independent cardinality/value checks.
  • Storage-interface matrix: memory/file source × no/committed/aborted competitor × unflushed/flushed target × same/new key. All 24 scenarios pass, including exact row count, values, old-key visibility, and restart checks. Adaptive same-process race stress passes 42 iterations / 1,008 scenarios (29.597s package elapsed).
  • A real two-block persisted source with a conflict only in the second block rejects the whole transaction. The first block does not partially commit; rollback and restart preserve the expected rows.
  • Deleting the real source file after AddDataFiles produces ErrFileNotFound at commit; rollback and restart preserve the predecessor. Injected context cancellation during traversal does not advance coverage; retry checks the same interval and vector-pool usage returns to zero. Both challenges pass under race detection.
  • Independent reference models pass 448 index window/abort-mask combinations and 132 inclusive timestamp windows across data and tombstones under race detection. Restoring the old index implementation makes the model fail at [0,1). The earlier persisted-source challenge also fails when only the old shared watermark is restored, demonstrating that these oracles distinguish the original defects.

These additional QA tests were executed through external Go overlays and are not committed tests in this PR. Existing exact-head four-package normal/race/static results and original regression stress remain valid; all eight tracked-file hashes still match and the worktree is clean.

Ownership/unhappy-path audit: coverage belongs to the existing stream owner; cleanup owners remain intact, no new wait edge or lifecycle owner is introduced, and added state is bounded scalar state. Extra scans restore required coverage. No large-scale performance benchmark, power-loss test, or network-partition challenge was performed; the SQL results do not establish a proof for every pessimistic transaction schedule.

Non-blocking recommendation: preserve the distinct real-file/flushed-competitor and later-block conflict cases within the existing destination-key regression suite, reusing its fixture. Do not copy the entire external QA matrix into the PR. No production change is requested.

Latest CI: shared build, arm64 SCA, coverage, proxy BVT, and pessimistic BVT are green. Ubuntu UT is still in progress; it is not counted as passed in this review.

This branch was previously deployed

1 inactive deployment
ci — 461417be Deployed Oct 8, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] TAE TestDelete4 intermittently reports an off-by-one value

2 participants