Repository navigation
fix(frontend): stop DATA BRANCH DIFF SQL output closing the borrowed shared file service - #30769
Conversation
…shared file service ## Summary - prepareFSForDiffAsFile now closes only the ETL service it creates for SQL-format diff output files; the borrowed process-wide SHARED file service is never closed by preparation failure, mutable release, or streaming release - new releaseDiffTargetFS chains the owned mutator/writer release before the single terminal Close of the operation-created ETL service, and returns borrowed releases unwrapped - newSingleWriteAppender's release closes its pipe endpoint and joins the writer task, and no longer closes the caller-supplied file service, whose lifetime stays at the acquisition boundary ## Verification - focused borrowed-service tests failed on base 0276f82 (borrowed Close count 1 on preparation failure, streaming release, streaming write failure, mutable release, and mutator close failure) and pass after the change - each diff-touched streaming lifecycle test measured once under -race (T=0.00-0.01s) and stress-run 100 times via -race -count=100, all exit 0 - full ./pkg/frontend green without a test-name filter in normal mode (ok 25.873s) and under -race (ok 59.567s); gofmt/vet/golangci-lint clean
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? |
|
Unrelated UT-failure record — attempt 1 of run 39716108348 UT Test on Ubuntu/x86 failed on two tests; the failed-job log shows both are outside this PR's delta:
This PR's own suite was green in the failed run itself ( |
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 15f41231f5e778b150a45cbb686d86d927ab1a0d
Assessment: approve
Reviewed the complete two-file delta and affected ownership, error and cancellation paths. The acquisition boundary correctly distinguishes borrowed services from owned ETL services, preserves writer completion and error propagation, and avoids registry-wide cache teardown. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Passed 12 focused tests and four ownership-policy subtests under -race, covering preparation failure, streaming success/failure, mutable release and close ordering.
-
Passed six individually selected streaming lifecycle tests with -race -count=100 each, using repetitions derived from measured test durations.
-
Preflight passed; tests used the supplied test-exec. Missing native prerequisites were recovered through repository make cgo, with 194 frozen input hashes verified.
-
Reconciled commands, source fingerprints, exit receipts and terminal logs in /home/xupeng/.local/state/mo-bot/jobs/e7a7c7cf55c4cf280c982262/attempt-1/validation-reconciliation.json. Source remains unchanged; git diff --check passed.
-
Reused frozen exact-head successful UT, coverage, static-analysis and multi-CN BVT results. Performance tracing found only constant-size release bookkeeping, with no added per-row work or I/O.
Limitations:
-
No local live-S3 teardown test or performance benchmark was run; ownership is verified through controlled tests and traced service implementations.
-
Raw CI logs and the linked issue body were not supplied. Earlier-base author test claims were not counted as fresh execution evidence.
Merge Queue Status
This pull request spent 18 minutes 28 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Related to #30755
What this PR does / why we need it:
Root cause
SQL-format
DATA BRANCH DIFF ... OUTPUT FILEwith aSHARED:/...target borrows the process-wide shared file service inprepareFSForDiffAsFile, but all three terminal paths calledtargetFS.Close(ctx)unconditionally: the preparation-error defer, the mutable release, andnewSingleWriteAppender's streaming release. A single diff operation therefore ran terminal cleanup of the long-lived service registry:FileServices.Closeiterates every registered service, and S3FS/LocalFS Close tear down their registered mem/disk caches.Change
pkg/frontend/data_branch_output.go:prepareFSForDiffAsFilenow recordsownsTargetFSonly in the branch that creates an ETL service viafileservice.GetForETL(implicit-local, stage-resolved, and dynamic ETL targets). The SHARED branch borrows the process service, and the preparation-error defer closes only the owned service; output deletion and error propagation are unchanged.releaseDiffTargetFSbuilds both releases: the owned mutator/writer release runs first, then exactly one terminalClosefor the operation-created ETL service, still returning the underlying error. A borrowed target service is returned unwrapped and never closed.newSingleWriteAppender's release now closes only its pipe endpoint and waits for the writer task; it no longer closes the caller-supplied target file service, whose lifetime stays at the acquisition boundary.Issue-to-test proof
pkg/frontend/data_branch_output_test.go, using counting shared-service surrogates over the realprepareFSForDiffAsFile/release/cleanuppath withSHARED:/difftargets:TestDataBranchOutputPrepFailureKeepsBorrowedSharedService- injected preparation delete failure: the injected error propagates, preparation delete + failure-cleanup delete both run, borrowed Close count 0.TestDataBranchOutputStreamingReleaseKeepsBorrowedSharedService- streaming success: the writer task finished before release returned (full SQL output captured), preparation and cleanup deletes run, borrowed Close count 0 and the service stays usable after release.TestDataBranchOutputStreamingWriteFailureKeepsBorrowedSharedService- injected streaming write failure: the write error propagates from writeFile and release, failed-output cleanup deletes, borrowed Close count 0.TestDataBranchOutputMutableReleaseKeepsBorrowedSharedService- mutable append path: the owned mutator closes exactly once on release, output appended correctly, borrowed Close count 0.TestDataBranchOutputMutableAppenderReturnsCloseFailure(strengthened) - mutator close failure still propagates while the borrowed service is never closed.TestReleaseDiffTargetFSOwnership- release policy: borrowed service never closed (also on writer error); owned ETL service closed exactly once, strictly after its owned writers finished, also on writer error.The same focused set failed on base 0276f82 with borrowed Close count 1 in every scenario above, so the red/green pair proves this change fixes the reported defect.
Test commands and results (CGo test wrapper, macOS/arm64, Go 1.27.1, head 0276f82 + this change)
.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s -run 'KeepsBorrowedSharedService|^TestDataBranchOutputMutableAppenderReturnsCloseFailure$' ./pkg/frontend- exit 1, borrowed Close count 1 on all scenarios (defect reproduced).-v- exit 0, all six tests plus four policy subtests PASS under-race.-race -json(T=0.00-0.01s, N=clamp(floor(30s/T),1,100)=100), then.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=120s -run '^<Test>$' ./pkg/frontendper test - all six exit 0..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=3600s ./pkg/frontend- exit 0,ok github.com/matrixorigin/matrixone/pkg/frontend 25.873s;.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=7200s ./pkg/frontend- exit 0,ok github.com/matrixorigin/matrixone/pkg/frontend 59.567s..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -v -timeout=600s -run 'DataBranchOutput|DataBranchDiff|DataBranchCSV|OnlineBranchApply' ./pkg/frontend- exit 0, 141 selected tests/subtests, 0 fail.gofmt -lon both changed files clean; with the repository CGo environment,go vet -mod=readonly ./pkg/frontend- exit 0 andgolangci-lint run -c .golangci.yml --new-from-rev 0276f82fb7 ./pkg/frontend- exit 0, 0 issues.Residual risks and limitations
go vet/golangci-lintonpkg/frontendrequire the repository CGo environment (CGO_CFLAGS/CGO_LDFLAGSpointing atcgo/andthirdparties/install); without it the cgo package fails to build and vet emits pan-package typecheck noise that is an environment failure, not a code failure.newSingleWriteAppenderno longer closes the target file service; its only production caller now wraps the release throughreleaseDiffTargetFS. All package-local direct callers were covered by the green full-package runs; none asserted close behavior.fileservice.GetForETLconstructs services internally and provides no injection seam; the borrowed branch is proven end to end.