Skip to content

sctest: fix three defects in Rollback/Pause cumulative stage discovery - #173203

Open
waterWang wants to merge 1 commit into
cockroachdb:masterfrom
waterWang:fix/sctest-stage-discovery-rollback-pause
Open

sctest: fix three defects in Rollback/Pause cumulative stage discovery#173203
waterWang wants to merge 1 commit into
cockroachdb:masterfrom
waterWang:fix/sctest-stage-discovery-rollback-pause

Conversation

@waterWang

Copy link
Copy Markdown

Summary

The shared-cluster refactor of the cumulative schema changer test suites (commit 15081f2cf3c) introduced three defects in pkg/sql/schemachanger/sctest/cumulative.go. Their combined effect is that a large portion of the generated TestRollback_* and TestPause_* tests have been silently skipping since the refactor, and once the skipping is fixed, two further defects cause failures for tests that then actually run.

Defect 1: Stage discovery is poisoned by setup statements (tests silently skip)

stageDiscovery.countStagesOnce recorded post-commit stage counts from the first plan the BeforeStage knob observed. Because the knob is installed at cluster creation, any setup statement that runs through the declarative schema changer (e.g. CREATE SEQUENCE, CREATE INDEX) plans with zero post-commit stages, locking in 0 and causing cumulativeTestForEachPostCommitStage to skip with "test case has no post-commit stages".

Fix: Replace countStagesOnce (first-plan-wins) with observe, which overwrites the counts on every observed plan until freeze is called after the discovery pass completes. The last-observed (job) plan therefore wins, and multi-statement test definitions are also enabled.

Defect 2: rollbackCase/pauseCase drop the database but never recreate it

Both drop the test database and re-run setup without recreating it. Definitions that implicitly use defaultdb re-run their setup against system and fail with pq: user root does not have CREATE privilege on database system. The Backup flavor already handles this correctly by executing cs.CreateDatabaseStmt after the drop.

Fix: Recreate the database via cs.CreateDatabaseStmt after the drop in both rollbackCase and pauseCase, matching the Backup behavior.

Defect 3: Rollback() stops its shared server via t.Cleanup, causing spurious "leaked stopper" failures

t.Cleanup runs after the generated caller's defer log.Scope(t).Close(t), so the log scope teardown observes the still-running server and fails the test with leaked stopper. Pause() uses a plain defer and does not have this problem.

Fix: Stop the Rollback server with defer instead of t.Cleanup, matching Pause().

How to verify

  • dev test pkg/sql/schemachanger -f 'TestRollback_add_column$' -v — previously completed in ~2s having skipped with "test case has no post-commit stages"; now runs the rollback scenarios.
  • dev test pkg/sql/schemachanger -f 'TestRollback_alter_table_add_check_vanilla$' -v — previously failed with user root does not have CREATE privilege on database system and leaked stopper; now succeeds.

Closes #173199

@waterWang
waterWang requested a review from a team as a code owner August 7, 2026 20:13
@waterWang
waterWang requested review from spilchen and removed request for a team August 7, 2026 20:13
@blathers-crl

blathers-crl Bot commented Aug 7, 2026

Copy link
Copy Markdown

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

Before a member of our team reviews your PR, I have some potential action items for you:

  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl Bot added the O-community Originated from the community label Aug 7, 2026
@cockroachlabs-cla-agent

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sctest: Rollback and Pause tests silently skip or fail after shared-cluster refactor

1 participant