sctest: fix three defects in Rollback/Pause cumulative stage discovery - #173203
Open
waterWang wants to merge 1 commit into
Open
sctest: fix three defects in Rollback/Pause cumulative stage discovery#173203waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
|
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:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The shared-cluster refactor of the cumulative schema changer test suites (commit
15081f2cf3c) introduced three defects inpkg/sql/schemachanger/sctest/cumulative.go. Their combined effect is that a large portion of the generatedTestRollback_*andTestPause_*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.countStagesOncerecorded post-commit stage counts from the first plan theBeforeStageknob 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 causingcumulativeTestForEachPostCommitStageto skip with"test case has no post-commit stages".Fix: Replace
countStagesOnce(first-plan-wins) withobserve, which overwrites the counts on every observed plan untilfreezeis called after the discovery pass completes. The last-observed (job) plan therefore wins, and multi-statement test definitions are also enabled.Defect 2:
rollbackCase/pauseCasedrop the database but never recreate itBoth drop the test database and re-run setup without recreating it. Definitions that implicitly use
defaultdbre-run their setup againstsystemand fail withpq: user root does not have CREATE privilege on database system. The Backup flavor already handles this correctly by executingcs.CreateDatabaseStmtafter the drop.Fix: Recreate the database via
cs.CreateDatabaseStmtafter the drop in bothrollbackCaseandpauseCase, matching the Backup behavior.Defect 3:
Rollback()stops its shared server viat.Cleanup, causing spurious "leaked stopper" failurest.Cleanupruns after the generated caller'sdefer log.Scope(t).Close(t), so the log scope teardown observes the still-running server and fails the test withleaked stopper.Pause()uses a plaindeferand does not have this problem.Fix: Stop the Rollback server with
deferinstead oft.Cleanup, matchingPause().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 withuser root does not have CREATE privilege on database systemandleaked stopper; now succeeds.Closes #173199