Skip to content

test: remove redundant data branch teardown - #28099

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:xp/fix-issue-28098-data-branch-cleanup
Sep 3, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:xp/fix-issue-28098-data-branch-cleanup

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #28098

Root cause

TestIssue26111DataBranchDatabaseWithCyclicForeignKeys owns a fresh embedded cluster with a unique private data path, but also performed SQL pre-clean and deferred teardown for an account, a snapshot, and four databases.

All deferred SQL cleanup shared one 30-second context. DROP ACCOUNT expands into many catalog DDL/DML operations, so its cost grows with the tenant catalog. In the failed CI run, functional assertions completed around 08:17:32; DROP ACCOUNT then consumed almost the entire cleanup budget, and the later DROP DATABASE issue_26111_branch inherited the expired context and failed. Connection-refused messages appeared only during subsequent cluster shutdown and were downstream noise.

What this PR does

  • Remove fixture pre-clean that cannot be needed in a fresh private cluster.
  • Remove scale-dependent bulk SQL teardown; cluster ownership provides fixture isolation.
  • Preserve DROP DATABASE issue_26111_branch as an explicit product oracle under the main 180-second test context. A branch with restored cyclic foreign keys must remain droppable.

This corrects lifecycle ownership; it does not increase a timeout or add retries.

Correctness and coverage

The regression still verifies:

  • existing-target rejection and restoration of session foreign_key_checks;
  • current-state and snapshot branches;
  • cross-account visibility;
  • copied rows and cyclic foreign-key metadata remapping;
  • FK enforcement in every created branch;
  • duplicate cross-account target rejection without partial mutation;
  • successful drop of a branch containing restored cyclic foreign keys.

Snapshot, source, auxiliary target, and account deletion were fixture cleanup rather than contracts of issue #26111. DROP ACCOUNT lifecycle behavior remains independently covered by TestIssue27719DropAccountCleansSQLTaskLifecycle.

Risk and unhappy paths

  • On any mid-test FailNow, opened sql.DB handles close through function defers before t.Cleanup closes the cluster.
  • No later test can observe retained SQL state: StartTestCluster allocates a separate cluster and data path for this fixture.
  • Body SQL and the explicit branch-drop oracle share the bounded 180-second context.
  • Removing the shared cleanup chain removes a wait path whose duration scaled with catalog size.
  • No production code, public SQL behavior, retry policy, or global timeout changes.

Performance

Same machine and focused command:

  • baseline: 16.52s;
  • revised focused run: 13.03s;
  • revised same-process repetitions: 15.93s, 13.08s, 15.88s.

Local steady-state change is small. On the loaded CI runner, this removes the approximately 30-second teardown tail and eliminates its catalog-size sensitivity.

Validation

  • focused test: PASS, 13.03s;
  • focused race test: PASS, 19.16s, no race;
  • same-process repetition: PASS 3/3;
  • owning package ./pkg/tests/issues/isolated: PASS 7/7, 136.14s;
  • git diff --check: PASS.

@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.

Deep review completed against main@2004c61075 and head b7bb5536d1.

One coverage gap was found during review: the original teardown used execSQLRequire, so deleting it also deleted the implicit assertion that a data branch containing restored cyclic foreign keys remains droppable. Fixed in b7bb5536d1 by retaining that operation as an explicit product oracle under the main bounded test context, while leaving account/snapshot/auxiliary database cleanup to the dedicated cluster owner.

Reviewed from correctness, regression-contract, performance, and unhappy-path/lifecycle angles:

  • all issue #26111 behavioral oracles remain covered;
  • failure paths close SQL handles before cluster cleanup;
  • retained fixture state cannot cross tests because the embedded cluster/data path is private;
  • the catalog-size-dependent shared 30s teardown chain is gone;
  • no production behavior, retry, or global timeout changes;
  • no remaining blocking finding.

Validation on the final head:

  • focused test PASS (13.03s);
  • race PASS (19.16s, no race);
  • repeated PASS 3/3 (15.93s / 13.08s / 15.88s);
  • owning package PASS 7/7 (136.14s);
  • diff check PASS.

CI for the new head is allowed to complete independently; the code review itself is clean.

@XuPeng-SH
XuPeng-SH merged commit 2691152 into matrixorigin:main Sep 3, 2026
26 checks passed
@XuPeng-SH
XuPeng-SH deleted the xp/fix-issue-28098-data-branch-cleanup branch September 3, 2026 22:45
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
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Code Refactoring
- [x] Test and CI

## Which issue(s) this PR fixes:

Fixes matrixorigin#28098

## Root cause

`TestIssue26111DataBranchDatabaseWithCyclicForeignKeys` owns a fresh
embedded cluster with a unique private data path, but also performed SQL
pre-clean and deferred teardown for an account, a snapshot, and four
databases.

All deferred SQL cleanup shared one 30-second context. `DROP ACCOUNT`
expands into many catalog DDL/DML operations, so its cost grows with the
tenant catalog. In the failed CI run, functional assertions completed
around 08:17:32; `DROP ACCOUNT` then consumed almost the entire cleanup
budget, and the later `DROP DATABASE issue_26111_branch` inherited the
expired context and failed. Connection-refused messages appeared only
during subsequent cluster shutdown and were downstream noise.

## What this PR does

- Remove fixture pre-clean that cannot be needed in a fresh private
cluster.
- Remove scale-dependent bulk SQL teardown; cluster ownership provides
fixture isolation.
- Preserve `DROP DATABASE issue_26111_branch` as an explicit product
oracle under the main 180-second test context. A branch with restored
cyclic foreign keys must remain droppable.

This corrects lifecycle ownership; it does not increase a timeout or add
retries.

## Correctness and coverage

The regression still verifies:

- existing-target rejection and restoration of session
`foreign_key_checks`;
- current-state and snapshot branches;
- cross-account visibility;
- copied rows and cyclic foreign-key metadata remapping;
- FK enforcement in every created branch;
- duplicate cross-account target rejection without partial mutation;
- successful drop of a branch containing restored cyclic foreign keys.

Snapshot, source, auxiliary target, and account deletion were fixture
cleanup rather than contracts of issue matrixorigin#26111. `DROP ACCOUNT` lifecycle
behavior remains independently covered by
`TestIssue27719DropAccountCleansSQLTaskLifecycle`.

## Risk and unhappy paths

- On any mid-test `FailNow`, opened `sql.DB` handles close through
function defers before `t.Cleanup` closes the cluster.
- No later test can observe retained SQL state: `StartTestCluster`
allocates a separate cluster and data path for this fixture.
- Body SQL and the explicit branch-drop oracle share the bounded
180-second context.
- Removing the shared cleanup chain removes a wait path whose duration
scaled with catalog size.
- No production code, public SQL behavior, retry policy, or global
timeout changes.

## Performance

Same machine and focused command:

- baseline: 16.52s;
- revised focused run: 13.03s;
- revised same-process repetitions: 15.93s, 13.08s, 15.88s.

Local steady-state change is small. On the loaded CI runner, this
removes the approximately 30-second teardown tail and eliminates its
catalog-size sensitivity.

## Validation

- focused test: PASS, 13.03s;
- focused race test: PASS, 19.16s, no race;
- same-process repetition: PASS 3/3;
- owning package `./pkg/tests/issues/isolated`: PASS 7/7, 136.14s;
- `git diff --check`: PASS.
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
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Code Refactoring
- [x] Test and CI

## Which issue(s) this PR fixes:

Fixes matrixorigin#28098

## Root cause

`TestIssue26111DataBranchDatabaseWithCyclicForeignKeys` owns a fresh
embedded cluster with a unique private data path, but also performed SQL
pre-clean and deferred teardown for an account, a snapshot, and four
databases.

All deferred SQL cleanup shared one 30-second context. `DROP ACCOUNT`
expands into many catalog DDL/DML operations, so its cost grows with the
tenant catalog. In the failed CI run, functional assertions completed
around 08:17:32; `DROP ACCOUNT` then consumed almost the entire cleanup
budget, and the later `DROP DATABASE issue_26111_branch` inherited the
expired context and failed. Connection-refused messages appeared only
during subsequent cluster shutdown and were downstream noise.

## What this PR does

- Remove fixture pre-clean that cannot be needed in a fresh private
cluster.
- Remove scale-dependent bulk SQL teardown; cluster ownership provides
fixture isolation.
- Preserve `DROP DATABASE issue_26111_branch` as an explicit product
oracle under the main 180-second test context. A branch with restored
cyclic foreign keys must remain droppable.

This corrects lifecycle ownership; it does not increase a timeout or add
retries.

## Correctness and coverage

The regression still verifies:

- existing-target rejection and restoration of session
`foreign_key_checks`;
- current-state and snapshot branches;
- cross-account visibility;
- copied rows and cyclic foreign-key metadata remapping;
- FK enforcement in every created branch;
- duplicate cross-account target rejection without partial mutation;
- successful drop of a branch containing restored cyclic foreign keys.

Snapshot, source, auxiliary target, and account deletion were fixture
cleanup rather than contracts of issue matrixorigin#26111. `DROP ACCOUNT` lifecycle
behavior remains independently covered by
`TestIssue27719DropAccountCleansSQLTaskLifecycle`.

## Risk and unhappy paths

- On any mid-test `FailNow`, opened `sql.DB` handles close through
function defers before `t.Cleanup` closes the cluster.
- No later test can observe retained SQL state: `StartTestCluster`
allocates a separate cluster and data path for this fixture.
- Body SQL and the explicit branch-drop oracle share the bounded
180-second context.
- Removing the shared cleanup chain removes a wait path whose duration
scaled with catalog size.
- No production code, public SQL behavior, retry policy, or global
timeout changes.

## Performance

Same machine and focused command:

- baseline: 16.52s;
- revised focused run: 13.03s;
- revised same-process repetitions: 15.93s, 13.08s, 15.88s.

Local steady-state change is small. On the loaded CI runner, this
removes the approximately 30-second teardown tail and eliminates its
catalog-size sensitivity.

## Validation

- focused test: PASS, 13.03s;
- focused race test: PASS, 19.16s, no race;
- same-process repetition: PASS 3/3;
- owning package `./pkg/tests/issues/isolated`: PASS 7/7, 136.14s;
- `git diff --check`: PASS.
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
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Code Refactoring
- [x] Test and CI

## Which issue(s) this PR fixes:

Fixes matrixorigin#28098

## Root cause

`TestIssue26111DataBranchDatabaseWithCyclicForeignKeys` owns a fresh
embedded cluster with a unique private data path, but also performed SQL
pre-clean and deferred teardown for an account, a snapshot, and four
databases.

All deferred SQL cleanup shared one 30-second context. `DROP ACCOUNT`
expands into many catalog DDL/DML operations, so its cost grows with the
tenant catalog. In the failed CI run, functional assertions completed
around 08:17:32; `DROP ACCOUNT` then consumed almost the entire cleanup
budget, and the later `DROP DATABASE issue_26111_branch` inherited the
expired context and failed. Connection-refused messages appeared only
during subsequent cluster shutdown and were downstream noise.

## What this PR does

- Remove fixture pre-clean that cannot be needed in a fresh private
cluster.
- Remove scale-dependent bulk SQL teardown; cluster ownership provides
fixture isolation.
- Preserve `DROP DATABASE issue_26111_branch` as an explicit product
oracle under the main 180-second test context. A branch with restored
cyclic foreign keys must remain droppable.

This corrects lifecycle ownership; it does not increase a timeout or add
retries.

## Correctness and coverage

The regression still verifies:

- existing-target rejection and restoration of session
`foreign_key_checks`;
- current-state and snapshot branches;
- cross-account visibility;
- copied rows and cyclic foreign-key metadata remapping;
- FK enforcement in every created branch;
- duplicate cross-account target rejection without partial mutation;
- successful drop of a branch containing restored cyclic foreign keys.

Snapshot, source, auxiliary target, and account deletion were fixture
cleanup rather than contracts of issue matrixorigin#26111. `DROP ACCOUNT` lifecycle
behavior remains independently covered by
`TestIssue27719DropAccountCleansSQLTaskLifecycle`.

## Risk and unhappy paths

- On any mid-test `FailNow`, opened `sql.DB` handles close through
function defers before `t.Cleanup` closes the cluster.
- No later test can observe retained SQL state: `StartTestCluster`
allocates a separate cluster and data path for this fixture.
- Body SQL and the explicit branch-drop oracle share the bounded
180-second context.
- Removing the shared cleanup chain removes a wait path whose duration
scaled with catalog size.
- No production code, public SQL behavior, retry policy, or global
timeout changes.

## Performance

Same machine and focused command:

- baseline: 16.52s;
- revised focused run: 13.03s;
- revised same-process repetitions: 15.93s, 13.08s, 15.88s.

Local steady-state change is small. On the loaded CI runner, this
removes the approximately 30-second teardown tail and eliminates its
catalog-size sensitivity.

## Validation

- focused test: PASS, 13.03s;
- focused race test: PASS, 19.16s, no race;
- same-process repetition: PASS 3/3;
- owning package `./pkg/tests/issues/isolated`: PASS 7/7, 136.14s;
- `git diff --check`: PASS.

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/enhancement kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flaky UT]: TestIssue26111 data-branch cleanup times out during embedded-cluster teardown

2 participants