Skip to content

workload: enable multi-region random schema workload#165751

Draft
shghasemi wants to merge 2 commits intocockroachdb:masterfrom
shghasemi:multi-region-workload
Draft

workload: enable multi-region random schema workload#165751
shghasemi wants to merge 2 commits intocockroachdb:masterfrom
shghasemi:multi-region-workload

Conversation

@shghasemi
Copy link
Contributor

@shghasemi shghasemi commented Mar 13, 2026

This change is stacked on another PR.

Previously, TestWorkload only ran against a single-region database,
because alterDatabasePrimaryRegion was disabled. This change fixes
several workload-related issues that cause test flakes in a
multi-region setup.

  1. The error screening query for concurrent schema changes is
    extended to detect declarative schema changer state involving primary
    index swaps (which includes regional-by-row transitions).
  2. The COMMENT ON TYPE operation now filters out the crdb_internal_region
    enum to avoid errors.

informs: #149491

Release note: None

@trunk-io
Copy link
Contributor

trunk-io bot commented Mar 13, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@shghasemi shghasemi force-pushed the multi-region-workload branch from 5e49c95 to b31cd03 Compare March 17, 2026 14:18
@shghasemi shghasemi changed the title workload: add multi-region random schema workload workload: enable multi-region random schema workload Mar 17, 2026
Previously, `ALTER DATABASE ... PRIMARY REGION` only refreshed table
zone configurations when placement was restricted or super regions
were involved. This was based on the assumption that REGIONAL BY TABLE
tables in the primary region never have explicit zone configs and can
always inherit from the database.

However, `ALTER DATABASE ... SURVIVE REGION FAILURE` writes explicit
zone configs on all tables (including RBT) because region failure
survival requires a tighter replica distribution. Additionally, users
can explicitly modify a table zone config. When the primary region is
changed, those explicit table zone configs retain stale voter_constraints
and lease_preferences pointing to the old primary region.

Fix this by calling `refreshZoneConfigsForTables` when switching the
primary region on `SURVIVE REGION FAILURE`. For tables without explicit
zone configs, the refresh is a no-op. For tables with stale explicit configs
(from a prior survival goal change), it updates them to reflect the new
primary region.

Informs: cockroachdb#149491
Informs: cockroachdb#83831

Release note (bug fix): Fixed a bug where `ALTER DATABASE ... PRIMARY
REGION` could leave stale zone configurations on tables, causing voter
constraints and lease preferences to reference the old primary region.
@shghasemi shghasemi force-pushed the multi-region-workload branch from b31cd03 to 2c478ff Compare March 23, 2026 15:49
Previously, TestWorkload only ran against a single-region database,
because alterDatabasePrimaryRegion was disabled. This change fixes
several workload-related issues that cause test flakes in a
multi-region setup.
1. The error screening query for concurrent schema changes is
extended to detect declarative schema changer state involving primary
index swaps (which includes regional-by-row transitions).
2. The COMMENT ON TYPE operation now filters out the crdb_internal_region
enum to avoid errors.

informs: cockroachdb#149491

Release note: None
@shghasemi shghasemi force-pushed the multi-region-workload branch from 2c478ff to 53a5b6f Compare March 23, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants