-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61073: sql: update database zone configurations after region drop finalization r=otan a=arulajmani Previously, database level zone configurations weren't updated when the region drop was finalized. This patch adds that support. This patch also moves setting zone configurations on ADD REGION from the user txn to the type schema changer. This ensures that zone configurations are added transactionally -- if the ADD REGION fails for whatever reason, we no longer leave behind dangling zone config. Lastly, I've refactored some test setup code that was being duplicated and improved the tests around rollback to test additional scenarios. Closes #60435 Closes #60750 Release note: None Release justification: bug fixes and low-risk updates to new functionality Co-authored-by: arulajmani <[email protected]>
- Loading branch information
Showing
10 changed files
with
262 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
13 changes: 13 additions & 0 deletions
13
pkg/ccl/multiregionccl/multiregionccltestutils/BUILD.bazel
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "multiregionccltestutils", | ||
srcs = ["testutils.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/ccl/multiregionccl/multiregionccltestutils", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/roachpb", | ||
"//pkg/testutils/serverutils", | ||
], | ||
) |
56 changes: 56 additions & 0 deletions
56
pkg/ccl/multiregionccl/multiregionccltestutils/testutils.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package multiregionccltestutils | ||
|
||
import ( | ||
"context" | ||
gosql "database/sql" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
) | ||
|
||
// TestingCreateMultiRegionCluster creates a test cluster with numServers number | ||
// of nodes and the provided testing knobs applied to each of the nodes. Every | ||
// node is placed in its own locality, named "us-east1", "us-east2", and so on. | ||
func TestingCreateMultiRegionCluster( | ||
t *testing.T, numServers int, knobs base.TestingKnobs, | ||
) (serverutils.TestClusterInterface, *gosql.DB, func()) { | ||
serverArgs := make(map[int]base.TestServerArgs) | ||
regionNames := make([]string, numServers) | ||
for i := 0; i < numServers; i++ { | ||
// "us-east1", "us-east2"... | ||
regionNames[i] = fmt.Sprintf("us-east%d", i+1) | ||
} | ||
|
||
for i := 0; i < numServers; i++ { | ||
serverArgs[i] = base.TestServerArgs{ | ||
Knobs: knobs, | ||
Locality: roachpb.Locality{ | ||
Tiers: []roachpb.Tier{{Key: "region", Value: regionNames[i]}}, | ||
}, | ||
} | ||
} | ||
|
||
tc := serverutils.StartNewTestCluster(t, numServers, base.TestClusterArgs{ | ||
ServerArgsPerNode: serverArgs, | ||
}) | ||
|
||
ctx := context.Background() | ||
cleanup := func() { | ||
tc.Stopper().Stop(ctx) | ||
} | ||
|
||
sqlDB := tc.ServerConn(0) | ||
|
||
return tc, sqlDB, cleanup | ||
} |
Oops, something went wrong.