Skip to content

test: stabilize authenticated cluster heartbeats - #26448

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
ck89119:issue-26441-main
Jul 31, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
ck89119:issue-26441-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 30, 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:

issue #26441

What this PR does / why we need it:

The authenticated issue tests previously started a second persistent embedded
LogService/TN cluster in the same UT process. Under race-enabled CI scheduling
pressure, the two clusters competed for Dragonboat tick/proposal processing,
which could starve HAKeeper heartbeats and reset a foreground SQL connection.

This PR routes authenticated issue tests through the existing
RunBaseClusterTests cluster instead of creating a second cluster. Because
that base cluster is shared by all RunBaseClusterTests callers, the test-only
configuration changes apply to every base-cluster consumer:

  • authentication remains enabled on the shared CN services;
  • CN and TN HAKeeper heartbeat RPC deadlines are 30 seconds;
  • HAKeeper CN and TN store expiration windows are 60 seconds, keeping the
    heartbeat deadline strictly below the liveness window;
  • the Iceberg tenant test uses the tenant's accountadmin role now that the
    shared cluster enforces authentication.

TestAuthenticatedTestsReuseBaseCluster verifies cluster identity and the
effective CN, TN, and LogService timeout configuration. Production defaults,
SQL behavior, assertions, and retry semantics are unchanged.

Validation:

  • .agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues -run '^TestAuthenticatedTestsReuseBaseCluster$' -count=1
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues -run '^TestIssue26114LegacyCrossAccountMetadataCountsTowardTargetQuota$' -count=10
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/embed -run '^TestIcebergSQLEngineEmbeddedWriteDMLAndMaintenanceSQL$' -count=1
  • make build
  • make static-check
  • git diff --check

@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

Choose a reason for hiding this comment

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

Re-reviewed the updated PR at a5d23de. The previous blocker is resolved: the shared embedded cluster now explicitly sets a 30s HAKeeper heartbeat and 60s CN/TN store timeouts, and the regression test inspects every CN/TN/LOG service and asserts the required ordering rather than only pointer reuse/auth state. The focused real-cluster test and full pkg/embed package passed under -race, and exact-head required CI is green.

@mergify mergify Bot added the queued label Jul 31, 2026
@mergify

mergify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-31 08:41 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-31 09:14 UTC · at 4e4c3bb63fd6a99d7fc5199668c0077f0d753739

This pull request spent 32 minutes 49 seconds in the queue, with no time running CI.

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

Reason

Pull request #26448 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit fb7dc32 into matrixorigin:main Jul 31, 2026
22 of 24 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 31, 2026
@ck89119
ck89119 deleted the issue-26441-main branch July 31, 2026 09:17
XuPeng-SH pushed a commit that referenced this pull request Jul 31, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #26054

## What this PR does / why we need it:

### Root cause

`DATA BRANCH DIFF ... OUTPUT FILE` treated successful producer-side
appends as a completed file write. In the streaming path,
`FileService.Write` ran in a worker and its final result was consumed
only by a no-result `release` callback. A file service could therefore
consume the entire pipe, let every `writeFile` call succeed, and then
return an error that the SQL statement could not observe. The mutable
path similarly discarded the final `Mutator.Close` error. In both cases
the success row was added before deferred finalization ran.

### Changes

- Make the common file-output finalizer return an error.
- Await and return the worker's final `FileService.Write` result in the
non-mutable path.
- Return the final `Mutator.Close` result in the mutable path.
- Explicitly finalize the output before adding the success result row,
and retain deferred finalization for early-error paths.
- Join an early statement error with any concurrent finalization error
instead of discarding either one.
- Finalize the writer before deleting partial output so cleanup cannot
race an active stream.
- Add focused tests for a file service that consumes the complete stream
before failing, SQL-level error/result-row/cleanup behavior, mutable
close failure propagation, success, immediate write failure, and setup
failures.

No public API, SQL syntax, output format, or configuration behavior
changes.

### Tests

Pre-fix reproduction on `main` used a package-level file service wrapper
that fully consumed each `ReaderForWrite` before returning `mock late
write failure`. In 3/3 runs, both `BEGIN` and `COMMIT` writes returned
nil, and the no-result release callback was the only observer of the
failure.

Post-fix exhaustive verification on `main@84f0d11`:

- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- Focused output-file regression set, `-count=3` (9 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m
./pkg/frontend` (PASS, 24.471s)
- Race selection was enumerated and contained all 7 new/modified
behavioral tests.
- Race measurements were `T=0s` to `0.04s`; with `B=30s`, the adaptive
rule selected `N=100` for every test.
- Each selected exact test passed independently with `-race -count=100`.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m
./pkg/frontend` (PASS, 37.818s)
- `git diff --check origin/main...HEAD`

Rebase verification on `main@0b8b53d`:

- Focused output-file finalization set, `-count=3` (8 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1`
(PASS, 33.817s)
- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- `git diff --check origin/main...HEAD`
- `git range-diff` confirmed the rebase preserved the patch exactly.

BVT is not appropriate for this regression because the required boundary
is a deterministic post-consumption `FileService.Write` or
`Mutator.Close` fault, which the SQL BVT harness cannot inject. The
package-level tests cover both file-service implementations and the SQL
result-row boundary directly.

### CI follow-up

Two attempt-1 Ubuntu/x86 UT failures were proven unrelated to this PR;
in both jobs, `pkg/frontend` passed and the failures were in packages
outside this two-file diff. The first failure exposed ISCP,
embedded-cluster heartbeat, and lockservice signatures: the previously
unreported ISCP cases were filed as #26517, while existing #26374 and
#26441 / #26448 cover the other signatures. After rebasing, a second
failure exposed current-main embedded-cluster heartbeat/reset cases and
was filed as #26522. Per CI policy, the failed jobs for the current-head
workflow were rerun exactly once; attempt 2 passed.

### Residual risks

No known correctness gap remains in final write/close error propagation.
Partial-output deletion retains the existing best-effort cleanup
contract: this change guarantees cleanup is invoked after writer
termination, but a backend `Delete` failure remains secondary to the
original output failure and is not returned separately.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26441

## What this PR does / why we need it:

The authenticated issue tests previously started a second persistent
embedded
LogService/TN cluster in the same UT process. Under race-enabled CI
scheduling
pressure, the two clusters competed for Dragonboat tick/proposal
processing,
which could starve HAKeeper heartbeats and reset a foreground SQL
connection.

This PR routes authenticated issue tests through the existing
`RunBaseClusterTests` cluster instead of creating a second cluster.
Because
that base cluster is shared by all `RunBaseClusterTests` callers, the
test-only
configuration changes apply to every base-cluster consumer:

- authentication remains enabled on the shared CN services;
- CN and TN HAKeeper heartbeat RPC deadlines are 30 seconds;
- HAKeeper CN and TN store expiration windows are 60 seconds, keeping
the
  heartbeat deadline strictly below the liveness window;
- the Iceberg tenant test uses the tenant's `accountadmin` role now that
the
  shared cluster enforces authentication.

`TestAuthenticatedTestsReuseBaseCluster` verifies cluster identity and
the
effective CN, TN, and LogService timeout configuration. Production
defaults,
SQL behavior, assertions, and retry semantics are unchanged.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
  '^TestAuthenticatedTestsReuseBaseCluster$' -count=1`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
'^TestIssue26114LegacyCrossAccountMetadataCountsTowardTargetQuota$'
-count=10`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/embed -run
  '^TestIcebergSQLEngineEmbeddedWriteDMLAndMaintenanceSQL$' -count=1`
- `make build`
- `make static-check`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26505)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26054

## What this PR does / why we need it:

### Root cause

`DATA BRANCH DIFF ... OUTPUT FILE` treated successful producer-side
appends as a completed file write. In the streaming path,
`FileService.Write` ran in a worker and its final result was consumed
only by a no-result `release` callback. A file service could therefore
consume the entire pipe, let every `writeFile` call succeed, and then
return an error that the SQL statement could not observe. The mutable
path similarly discarded the final `Mutator.Close` error. In both cases
the success row was added before deferred finalization ran.

### Changes

- Make the common file-output finalizer return an error.
- Await and return the worker's final `FileService.Write` result in the
non-mutable path.
- Return the final `Mutator.Close` result in the mutable path.
- Explicitly finalize the output before adding the success result row,
and retain deferred finalization for early-error paths.
- Join an early statement error with any concurrent finalization error
instead of discarding either one.
- Finalize the writer before deleting partial output so cleanup cannot
race an active stream.
- Add focused tests for a file service that consumes the complete stream
before failing, SQL-level error/result-row/cleanup behavior, mutable
close failure propagation, success, immediate write failure, and setup
failures.

No public API, SQL syntax, output format, or configuration behavior
changes.

### Tests

Pre-fix reproduction on `main` used a package-level file service wrapper
that fully consumed each `ReaderForWrite` before returning `mock late
write failure`. In 3/3 runs, both `BEGIN` and `COMMIT` writes returned
nil, and the no-result release callback was the only observer of the
failure.

Post-fix exhaustive verification on `main@84f0d11`:

- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- Focused output-file regression set, `-count=3` (9 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m
./pkg/frontend` (PASS, 24.471s)
- Race selection was enumerated and contained all 7 new/modified
behavioral tests.
- Race measurements were `T=0s` to `0.04s`; with `B=30s`, the adaptive
rule selected `N=100` for every test.
- Each selected exact test passed independently with `-race -count=100`.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m
./pkg/frontend` (PASS, 37.818s)
- `git diff --check origin/main...HEAD`

Rebase verification on `main@0b8b53d`:

- Focused output-file finalization set, `-count=3` (8 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1`
(PASS, 33.817s)
- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- `git diff --check origin/main...HEAD`
- `git range-diff` confirmed the rebase preserved the patch exactly.

BVT is not appropriate for this regression because the required boundary
is a deterministic post-consumption `FileService.Write` or
`Mutator.Close` fault, which the SQL BVT harness cannot inject. The
package-level tests cover both file-service implementations and the SQL
result-row boundary directly.

### CI follow-up

Two attempt-1 Ubuntu/x86 UT failures were proven unrelated to this PR;
in both jobs, `pkg/frontend` passed and the failures were in packages
outside this two-file diff. The first failure exposed ISCP,
embedded-cluster heartbeat, and lockservice signatures: the previously
unreported ISCP cases were filed as matrixorigin#26517, while existing matrixorigin#26374 and
matrixorigin#26441 / matrixorigin#26448 cover the other signatures. After rebasing, a second
failure exposed current-main embedded-cluster heartbeat/reset cases and
was filed as matrixorigin#26522. Per CI policy, the failed jobs for the current-head
workflow were rerun exactly once; attempt 2 passed.

### Residual risks

No known correctness gap remains in final write/close error propagation.
Partial-output deletion retains the existing best-effort cleanup
contract: this change guarantees cleanup is invoked after writer
termination, but a backend `Delete` failure remains secondary to the
original output failure and is not returned separately.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26441

## What this PR does / why we need it:

The authenticated issue tests previously started a second persistent
embedded
LogService/TN cluster in the same UT process. Under race-enabled CI
scheduling
pressure, the two clusters competed for Dragonboat tick/proposal
processing,
which could starve HAKeeper heartbeats and reset a foreground SQL
connection.

This PR routes authenticated issue tests through the existing
`RunBaseClusterTests` cluster instead of creating a second cluster.
Because
that base cluster is shared by all `RunBaseClusterTests` callers, the
test-only
configuration changes apply to every base-cluster consumer:

- authentication remains enabled on the shared CN services;
- CN and TN HAKeeper heartbeat RPC deadlines are 30 seconds;
- HAKeeper CN and TN store expiration windows are 60 seconds, keeping
the
  heartbeat deadline strictly below the liveness window;
- the Iceberg tenant test uses the tenant's `accountadmin` role now that
the
  shared cluster enforces authentication.

`TestAuthenticatedTestsReuseBaseCluster` verifies cluster identity and
the
effective CN, TN, and LogService timeout configuration. Production
defaults,
SQL behavior, assertions, and retry semantics are unchanged.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
  '^TestAuthenticatedTestsReuseBaseCluster$' -count=1`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
'^TestIssue26114LegacyCrossAccountMetadataCountsTowardTargetQuota$'
-count=10`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/embed -run
  '^TestIcebergSQLEngineEmbeddedWriteDMLAndMaintenanceSQL$' -count=1`
- `make build`
- `make static-check`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26505)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26054

## What this PR does / why we need it:

### Root cause

`DATA BRANCH DIFF ... OUTPUT FILE` treated successful producer-side
appends as a completed file write. In the streaming path,
`FileService.Write` ran in a worker and its final result was consumed
only by a no-result `release` callback. A file service could therefore
consume the entire pipe, let every `writeFile` call succeed, and then
return an error that the SQL statement could not observe. The mutable
path similarly discarded the final `Mutator.Close` error. In both cases
the success row was added before deferred finalization ran.

### Changes

- Make the common file-output finalizer return an error.
- Await and return the worker's final `FileService.Write` result in the
non-mutable path.
- Return the final `Mutator.Close` result in the mutable path.
- Explicitly finalize the output before adding the success result row,
and retain deferred finalization for early-error paths.
- Join an early statement error with any concurrent finalization error
instead of discarding either one.
- Finalize the writer before deleting partial output so cleanup cannot
race an active stream.
- Add focused tests for a file service that consumes the complete stream
before failing, SQL-level error/result-row/cleanup behavior, mutable
close failure propagation, success, immediate write failure, and setup
failures.

No public API, SQL syntax, output format, or configuration behavior
changes.

### Tests

Pre-fix reproduction on `main` used a package-level file service wrapper
that fully consumed each `ReaderForWrite` before returning `mock late
write failure`. In 3/3 runs, both `BEGIN` and `COMMIT` writes returned
nil, and the no-result release callback was the only observer of the
failure.

Post-fix exhaustive verification on `main@84f0d11`:

- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- Focused output-file regression set, `-count=3` (9 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m
./pkg/frontend` (PASS, 24.471s)
- Race selection was enumerated and contained all 7 new/modified
behavioral tests.
- Race measurements were `T=0s` to `0.04s`; with `B=30s`, the adaptive
rule selected `N=100` for every test.
- Each selected exact test passed independently with `-race -count=100`.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m
./pkg/frontend` (PASS, 37.818s)
- `git diff --check origin/main...HEAD`

Rebase verification on `main@0b8b53d`:

- Focused output-file finalization set, `-count=3` (8 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1`
(PASS, 33.817s)
- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- `git diff --check origin/main...HEAD`
- `git range-diff` confirmed the rebase preserved the patch exactly.

BVT is not appropriate for this regression because the required boundary
is a deterministic post-consumption `FileService.Write` or
`Mutator.Close` fault, which the SQL BVT harness cannot inject. The
package-level tests cover both file-service implementations and the SQL
result-row boundary directly.

### CI follow-up

Two attempt-1 Ubuntu/x86 UT failures were proven unrelated to this PR;
in both jobs, `pkg/frontend` passed and the failures were in packages
outside this two-file diff. The first failure exposed ISCP,
embedded-cluster heartbeat, and lockservice signatures: the previously
unreported ISCP cases were filed as matrixorigin#26517, while existing matrixorigin#26374 and
matrixorigin#26441 / matrixorigin#26448 cover the other signatures. After rebasing, a second
failure exposed current-main embedded-cluster heartbeat/reset cases and
was filed as matrixorigin#26522. Per CI policy, the failed jobs for the current-head
workflow were rerun exactly once; attempt 2 passed.

### Residual risks

No known correctness gap remains in final write/close error propagation.
Partial-output deletion retains the existing best-effort cleanup
contract: this change guarantees cleanup is invoked after writer
termination, but a backend `Delete` failure remains secondary to the
original output failure and is not returned separately.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26441

## What this PR does / why we need it:

The authenticated issue tests previously started a second persistent
embedded
LogService/TN cluster in the same UT process. Under race-enabled CI
scheduling
pressure, the two clusters competed for Dragonboat tick/proposal
processing,
which could starve HAKeeper heartbeats and reset a foreground SQL
connection.

This PR routes authenticated issue tests through the existing
`RunBaseClusterTests` cluster instead of creating a second cluster.
Because
that base cluster is shared by all `RunBaseClusterTests` callers, the
test-only
configuration changes apply to every base-cluster consumer:

- authentication remains enabled on the shared CN services;
- CN and TN HAKeeper heartbeat RPC deadlines are 30 seconds;
- HAKeeper CN and TN store expiration windows are 60 seconds, keeping
the
  heartbeat deadline strictly below the liveness window;
- the Iceberg tenant test uses the tenant's `accountadmin` role now that
the
  shared cluster enforces authentication.

`TestAuthenticatedTestsReuseBaseCluster` verifies cluster identity and
the
effective CN, TN, and LogService timeout configuration. Production
defaults,
SQL behavior, assertions, and retry semantics are unchanged.

Validation:

- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
  '^TestAuthenticatedTestsReuseBaseCluster$' -count=1`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/tests/issues
-run
'^TestIssue26114LegacyCrossAccountMetadataCountsTowardTargetQuota$'
-count=10`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race ./pkg/embed -run
  '^TestIcebergSQLEngineEmbeddedWriteDMLAndMaintenanceSQL$' -count=1`
- `make build`
- `make static-check`
- `git diff --check`

---------

Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#26505)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26054

## What this PR does / why we need it:

### Root cause

`DATA BRANCH DIFF ... OUTPUT FILE` treated successful producer-side
appends as a completed file write. In the streaming path,
`FileService.Write` ran in a worker and its final result was consumed
only by a no-result `release` callback. A file service could therefore
consume the entire pipe, let every `writeFile` call succeed, and then
return an error that the SQL statement could not observe. The mutable
path similarly discarded the final `Mutator.Close` error. In both cases
the success row was added before deferred finalization ran.

### Changes

- Make the common file-output finalizer return an error.
- Await and return the worker's final `FileService.Write` result in the
non-mutable path.
- Return the final `Mutator.Close` result in the mutable path.
- Explicitly finalize the output before adding the success result row,
and retain deferred finalization for early-error paths.
- Join an early statement error with any concurrent finalization error
instead of discarding either one.
- Finalize the writer before deleting partial output so cleanup cannot
race an active stream.
- Add focused tests for a file service that consumes the complete stream
before failing, SQL-level error/result-row/cleanup behavior, mutable
close failure propagation, success, immediate write failure, and setup
failures.

No public API, SQL syntax, output format, or configuration behavior
changes.

### Tests

Pre-fix reproduction on `main` used a package-level file service wrapper
that fully consumed each `ReaderForWrite` before returning `mock late
write failure`. In 3/3 runs, both `BEGIN` and `COMMIT` writes returned
nil, and the no-result release callback was the only observer of the
failure.

Post-fix exhaustive verification on `main@84f0d11`:

- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- Focused output-file regression set, `-count=3` (9 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m
./pkg/frontend` (PASS, 24.471s)
- Race selection was enumerated and contained all 7 new/modified
behavioral tests.
- Race measurements were `T=0s` to `0.04s`; with `B=30s`, the adaptive
rule selected `N=100` for every test.
- Each selected exact test passed independently with `-race -count=100`.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m
./pkg/frontend` (PASS, 37.818s)
- `git diff --check origin/main...HEAD`

Rebase verification on `main@0b8b53d`:

- Focused output-file finalization set, `-count=3` (8 exact tests)
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1`
(PASS, 33.817s)
- CGo-configured `go build -mod=readonly ./pkg/frontend`
- CGo-configured `go vet -mod=readonly ./pkg/frontend`
- `git diff --check origin/main...HEAD`
- `git range-diff` confirmed the rebase preserved the patch exactly.

BVT is not appropriate for this regression because the required boundary
is a deterministic post-consumption `FileService.Write` or
`Mutator.Close` fault, which the SQL BVT harness cannot inject. The
package-level tests cover both file-service implementations and the SQL
result-row boundary directly.

### CI follow-up

Two attempt-1 Ubuntu/x86 UT failures were proven unrelated to this PR;
in both jobs, `pkg/frontend` passed and the failures were in packages
outside this two-file diff. The first failure exposed ISCP,
embedded-cluster heartbeat, and lockservice signatures: the previously
unreported ISCP cases were filed as matrixorigin#26517, while existing matrixorigin#26374 and
matrixorigin#26441 / matrixorigin#26448 cover the other signatures. After rebasing, a second
failure exposed current-main embedded-cluster heartbeat/reset cases and
was filed as matrixorigin#26522. Per CI policy, the failed jobs for the current-head
workflow were rerun exactly once; attempt 2 passed.

### Residual risks

No known correctness gap remains in final write/close error propagation.
Partial-output deletion retains the existing best-effort cleanup
contract: this change guarantees cleanup is invoked after writer
termination, but a backend `Delete` failure remains secondary to the
original output failure and is not returned separately.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — 4e4c3bb6 Deployed Jul 31, 2026 by mergify[bot] via Matrixone Utils CI / Coverage #43803
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 kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants