Skip to content

fix(tae): synchronize transfer page paths - #26527

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26523
Jul 31, 2026
Merged

mergify[bot] merged 7 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26523

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Jul 31, 2026 •

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 #26523

What this PR does / why we need it:

TransferHashPage.path was a composite value written by SetPath while loading, logging, and TTL cleanup read it without synchronization. The page TTL goroutine could therefore race path publication and observe a mixed path.

Path publication and terminal cleanup also form one resource-lifecycle state machine. A page may close before its persisted path is published, and one WriteTransferPage batch stores several pages in the same physical file. Page-local deletion is therefore insufficient: a late publisher can leak a file, while deleting for one closed page can invalidate still-live sibling pages.

This PR:

  • synchronizes all page path publication, reads, and terminal cleanup;
  • introduces one persisted-file cohort per successful write batch, shared by every page published from that file;
  • seals the cohort after publication and deletes the physical file exactly once only after the last live page releases it;
  • lets already-closed pages reject publication without deleting a file still owned by live siblings;
  • uses the same cohort publication path for normal write success and FileAlreadyExists recovery;
  • keeps file-service deletion outside page/cohort locks;
  • adds deterministic single-page and concurrent lifecycle tests, plus two-page tests covering partial/all closure for both write-success branches.

BVT is not applicable because this is an in-process Go concurrency and file-ownership bug with no SQL-visible semantic change.

Validation after the final code change and merge from main (using the repository CGo include/library environment):

  • focused lifecycle tests under -race -count=100
  • go test -race ./pkg/vm/engine/tae/db/test -run '^TestClearPersistTransferTable$' -count=14
  • go test -race ./pkg/vm/engine/tae/model -count=1
  • go test -race ./pkg/vm/engine/tae/db/test -count=1
  • go test ./pkg/vm/engine/tae/model ./pkg/vm/engine/tae/db/test -count=1
  • go vet ./pkg/vm/engine/tae/model ./pkg/vm/engine/tae/db/test

API, on-disk format, TTL timing, and transfer-file naming are unchanged. Cohort ownership may retain a shared file until its last page reaches terminal cleanup, which is required to keep live sibling pages loadable. File-service deletion errors retain the existing logged-error and temporary-file GC behavior.

@mergify mergify Bot added the kind/bug Something isn't working label Jul 31, 2026
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jul 31, 2026
@gouhongshen
gouhongshen marked this pull request as ready for review July 31, 2026 15:28
@gouhongshen
gouhongshen requested a review from XuPeng-SH as a code owner July 31, 2026 15:28
@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 →

@gouhongshen

Copy link
Copy Markdown
Contributor Author

Valid and fixed in 084774a. The physical file is now owned by one shared publication cohort rather than by any individual page: publication is sealed only after every page has accepted or rejected its path, and the file is deleted exactly once after sealing when the last live page releases it. This also covers a page closing after acceptance but before later siblings are published.

Both normal write success and FileAlreadyExists use the same cohort helper. TestWriteTransferPage_ClosedPagePublication deterministically covers mixed and all-closed two-page batches on both branches; focused lifecycle tests passed with -race -count=100, the original regression passed with -race -count=14, and the full model and TAE DB test packages passed with and without -race. Scoped go vet also passed.

@gouhongshen
gouhongshen requested a review from XuPeng-SH July 31, 2026 18:09

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved exact head 084774a after full lifecycle re-review.

The two prior blockers are closed. Path publication and terminal cleanup are linearized per page, while the shared physical file is owned by one sealed cohort: publication cannot delete the file mid-batch, partial closure preserves live siblings, and the last live page triggers exactly one deletion after sealing. File-service I/O stays outside page/cohort locks. Q1-Q3 review found no remaining leak, wait-cycle, or unbounded-growth defect.

Local validation on the exact head:

  • all four focused lifecycle tests passed under race independently at count=100;
  • full pkg/vm/engine/tae/model passed under race;
  • the original TestClearPersistTransferTable regression passed under race;
  • scoped go vet passed.

The added mutexes are confined to path publication, disk fallback, and terminal cleanup; the in-memory Transfer hot path is unchanged. UT/SCA CI were still running when this review was submitted, so merge remains gated on CI.

@mergify

mergify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-31 18:44 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-31 19:33 UTC · at 57428fb8b1c2ef277bea50416c3febacf7aaab09 · squash

This pull request spent 48 minutes 36 seconds in the queue, including 48 minutes 9 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

This branch was previously deployed

1 inactive deployment
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.

[Bug]: TransferHashPage path races with TTL cleanup in TestClearPersistTransferTable

3 participants