Skip to content

Commit 8b47bf4

Browse files
craig[bot]yuzefovichhealthy-podXiang-Gujbowens
committed
108973: roachtest: allow local execution of tests that need gs fixtures r=yuzefovich a=yuzefovich We recently (in a2ba442) skipped running some tests that need gs fixtures when ran not on gce cloud. However, I think it should be ok to run these tests locally too. Epic: None Release note: None 109514: upgrade: retry errors when dialing instances r=ajstorm a=healthy-pod Release note: None Epic: none Closes #108860 110068: sql: change ordering of (re)creating secondary indexes in ALTER PK r=Xiang-Gu a=Xiang-Gu If we alter the primary key on a table with secondary indexes, we will recreate those secondary indexes as well as creating a new unique secondary index on the old primary key column(s). Previously, in the legacy schema changer, we'd create the new unique secondary index first and then recreate all existing secondary indexes. This is different from how declarative schema changer processes ALTER PK, in which the ordering is the opposite. This is not an issue per se; the only time it shows a difference is when you inspect the table after altering PK via, say, `SHOW CREATE t`, where you'd then observe a slightly different ordering of the indexes. This is actually easier to change the legacy schema changer so both schema changer would produce the same ordering of secondary indexes after an ALTER PK. This will help clean several test cases. Epic: None Release note: None 110122: storage: deflake TestEngineKeyValidate r=RaduBerinde a=jbowens Average the allocs across many runs to avoid flakes from a single alloc (perhaps from the runtime or testing package?). Epic: None Fixes #109919. Release note: none Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: healthy-pod <[email protected]> Co-authored-by: Xiang Gu <[email protected]> Co-authored-by: Jackson Owens <[email protected]>
5 parents 86adbd4 + 6659d18 + 1f6e734 + c14033f + 114c01b commit 8b47bf4

19 files changed

+82
-139
lines changed

pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ CREATE TABLE public.t (
599599
u STRING NULL,
600600
e INT8 NOT NULL,
601601
CONSTRAINT t_pkey PRIMARY KEY (pk2 ASC),
602-
UNIQUE INDEX t_pk_key (pk ASC),
603602
UNIQUE INDEX t_u_key (u ASC),
604603
INDEX t_a_idx (a ASC),
605604
UNIQUE INDEX t_b_key (b ASC),
@@ -608,13 +607,15 @@ CREATE TABLE public.t (
608607
INDEX created_idx (c ASC),
609608
UNIQUE INDEX t_e_key (e ASC),
610609
UNIQUE INDEX unique_c_d (c ASC, d ASC),
610+
UNIQUE INDEX t_pk_key (pk ASC),
611611
FAMILY fam_0_pk_pk2_partition_by_a_b_c_d_j_u (pk, pk2, partition_by, a, b, c, d, j, u, e)
612612
) PARTITION ALL BY LIST (partition_by) (
613613
PARTITION one VALUES IN ((1)),
614614
PARTITION two VALUES IN ((2))
615615
)
616616
-- Warning: Partitioned table with no zone configurations.
617617

618+
618619
query TTB colnames
619620
SELECT index_name, column_name, implicit FROM crdb_internal.index_columns
620621
WHERE descriptor_name = 't' AND column_type = 'key'

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ CREATE TABLE public.regional_by_row_table (
531531
j JSONB NULL,
532532
crdb_region multi_region_test_db.public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::multi_region_test_db.public.crdb_internal_region,
533533
CONSTRAINT regional_by_row_table_pkey PRIMARY KEY (pk2 ASC),
534-
UNIQUE INDEX regional_by_row_table_pk_key (pk ASC),
535534
INDEX regional_by_row_table_a_idx (a ASC),
536535
UNIQUE INDEX regional_by_row_table_b_key (b ASC),
537536
INVERTED INDEX regional_by_row_table_j_idx (j),
538537
UNIQUE INDEX uniq_idx (a ASC) WHERE b > 0:::INT8,
539538
UNIQUE INDEX unique_b_a (b ASC, a ASC),
539+
UNIQUE INDEX regional_by_row_table_pk_key (pk ASC),
540540
FAMILY fam_0_pk_pk2_a_b_j_crdb_region (pk, pk2, a, b, j, crdb_region)
541541
) LOCALITY REGIONAL BY ROW;
542542
ALTER PARTITION "us-east-1" OF INDEX multi_region_test_db.public.regional_by_row_table@regional_by_row_table_a_idx CONFIGURE ZONE USING "gc.ttlseconds" = 10

pkg/ccl/logictestccl/testdata/logic_test/zone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,6 @@ t CREATE TABLE public.t (
11311131
z INT8 NULL,
11321132
w INT8 NULL,
11331133
CONSTRAINT t_pkey PRIMARY KEY (y ASC),
1134-
UNIQUE INDEX t_x_key (x ASC),
11351134
INDEX i1 (z ASC) PARTITION BY LIST (z) (
11361135
PARTITION p1 VALUES IN ((1), (2)),
11371136
PARTITION p2 VALUES IN ((3), (4))
@@ -1140,6 +1139,7 @@ t CREATE TABLE public.t (
11401139
PARTITION p3 VALUES IN ((5), (6)),
11411140
PARTITION p4 VALUES IN ((7), (8))
11421141
),
1142+
UNIQUE INDEX t_x_key (x ASC),
11431143
FAMILY fam_0_x_y_z_w (x, y, z, w)
11441144
);
11451145
ALTER PARTITION p1 OF INDEX test.public.t@i1 CONFIGURE ZONE USING

pkg/ccl/partitionccl/zone_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,12 +1026,12 @@ func TestPrimaryKeyChangeZoneConfigs(t *testing.T) {
10261026

10271027
// Our subzones should be spans prefixed with dropped copy of i1,
10281028
// dropped copy of i2, new copy of i1, and new copy of i2.
1029-
// These have ID's 2, 3, 8 and 10 respectively.
1029+
// These have ID's 2, 3, 6 and 8 respectively.
10301030
expectedSpans := []roachpb.Key{
10311031
table.IndexSpan(codec, 2 /* indexID */).Key,
10321032
table.IndexSpan(codec, 3 /* indexID */).Key,
1033+
table.IndexSpan(codec, 6 /* indexID */).Key,
10331034
table.IndexSpan(codec, 8 /* indexID */).Key,
1034-
table.IndexSpan(codec, 10 /* indexID */).Key,
10351035
}
10361036
if len(zone.SubzoneSpans) != len(expectedSpans) {
10371037
t.Fatalf("expected subzones to have length %d", len(expectedSpans))

pkg/cmd/roachtest/tests/backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ func registerBackup(r registry.Registry) {
895895
Leases: registry.MetamorphicLeases,
896896
EncryptionSupport: registry.EncryptionMetamorphic,
897897
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
898-
if c.Spec().Cloud != spec.GCE {
898+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
899899
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
900900
}
901901
runBackupMVCCRangeTombstones(ctx, t, c, mvccRangeTombstoneConfig{})

pkg/cmd/roachtest/tests/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func registerCopy(r registry.Registry) {
185185
Cluster: r.MakeClusterSpec(tc.nodes),
186186
Leases: registry.MetamorphicLeases,
187187
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
188-
if c.Spec().Cloud != spec.GCE {
188+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
189189
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
190190
}
191191
runCopy(ctx, t, c, tc.rows, tc.txn)

pkg/cmd/roachtest/tests/import.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func registerImportNodeShutdown(r registry.Registry) {
9292
Cluster: r.MakeClusterSpec(4),
9393
Leases: registry.MetamorphicLeases,
9494
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
95-
if c.Spec().Cloud != spec.GCE {
95+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
9696
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
9797
}
9898
c.Put(ctx, t.Cockroach(), "./cockroach")
@@ -110,7 +110,7 @@ func registerImportNodeShutdown(r registry.Registry) {
110110
Cluster: r.MakeClusterSpec(4),
111111
Leases: registry.MetamorphicLeases,
112112
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
113-
if c.Spec().Cloud != spec.GCE {
113+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
114114
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
115115
}
116116
c.Put(ctx, t.Cockroach(), "./cockroach")
@@ -227,7 +227,7 @@ func registerImportTPCH(r registry.Registry) {
227227
EncryptionSupport: registry.EncryptionMetamorphic,
228228
Leases: registry.MetamorphicLeases,
229229
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
230-
if c.Spec().Cloud != spec.GCE {
230+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
231231
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
232232
}
233233
tick, perfBuf := initBulkJobPerfArtifacts(t.Name(), item.timeout)

pkg/cmd/roachtest/tests/import_cancellation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func registerImportCancellation(r registry.Registry) {
3737
Cluster: r.MakeClusterSpec(6, spec.CPU(32)),
3838
Leases: registry.MetamorphicLeases,
3939
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
40-
if c.Spec().Cloud != spec.GCE {
40+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
4141
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
4242
}
4343
runImportCancellation(ctx, t, c)

pkg/cmd/roachtest/tests/mixed_version_backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2122,7 +2122,7 @@ func registerBackupMixedVersion(r registry.Registry) {
21222122
EncryptionSupport: registry.EncryptionMetamorphic,
21232123
RequiresLicense: true,
21242124
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
2125-
if c.Spec().Cloud != spec.GCE {
2125+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
21262126
t.Skip("uses gs://cockroachdb-backup-testing; see https://github.com/cockroachdb/cockroach/issues/105968")
21272127
}
21282128

pkg/cmd/roachtest/tests/mixed_version_decl_schemachange_compat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func registerDeclSchemaChangeCompatMixedVersions(r registry.Registry) {
3232
Owner: registry.OwnerSQLFoundations,
3333
Cluster: r.MakeClusterSpec(1),
3434
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
35-
if c.Spec().Cloud != spec.GCE {
35+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
3636
t.Skip("uses gs://cockroach-corpus; see https://github.com/cockroachdb/cockroach/issues/105968")
3737
}
3838
runDeclSchemaChangeCompatMixedVersions(ctx, t, c, t.BuildVersion())

pkg/cmd/roachtest/tests/schemachange.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func registerSchemaChangeDuringKV(r registry.Registry) {
3434
Cluster: r.MakeClusterSpec(5),
3535
Leases: registry.MetamorphicLeases,
3636
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
37-
if c.Spec().Cloud != spec.GCE {
37+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
3838
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
3939
}
4040
const fixturePath = `gs://cockroach-fixtures/workload/tpch/scalefactor=10/backup?AUTH=implicit`

pkg/cmd/roachtest/tests/sqlsmith.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ WITH into_db = 'defaultdb', unsafe_restore_incompatible_version;
317317
// NB: sqlsmith failures should never block a release.
318318
NonReleaseBlocker: true,
319319
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
320-
if c.Spec().Cloud != spec.GCE {
320+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
321321
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
322322
}
323323
runSQLSmith(ctx, t, c, setup, setting)

pkg/cmd/roachtest/tests/tpc_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func loadTPCHDataset(
4444
disableMergeQueue bool,
4545
secure bool,
4646
) (retErr error) {
47-
if c.Spec().Cloud != spec.GCE {
47+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
4848
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
4949
}
5050

pkg/cmd/roachtest/tests/tpcdsvec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ WITH unsafe_restore_incompatible_version;
191191
Benchmark: true,
192192
Cluster: r.MakeClusterSpec(3),
193193
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
194-
if c.Spec().Cloud != spec.GCE {
194+
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
195195
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
196196
}
197197
runTPCDSVec(ctx, t, c)

pkg/sql/alter_primary_key.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -377,40 +377,6 @@ func (p *planner) AlterPrimaryKey(
377377
)
378378
}
379379

380-
// Create a new index that indexes everything the old primary index
381-
// does, but doesn't store anything.
382-
if shouldCopyPrimaryKey(tableDesc, newPrimaryIndexDesc, alterPrimaryKeyLocalitySwap) {
383-
newUniqueIdx := tableDesc.GetPrimaryIndex().IndexDescDeepCopy()
384-
// Clear the following fields so that they get generated by AllocateIDs.
385-
newUniqueIdx.ID = 0
386-
newUniqueIdx.Name = ""
387-
newUniqueIdx.StoreColumnIDs = nil
388-
newUniqueIdx.StoreColumnNames = nil
389-
newUniqueIdx.KeySuffixColumnIDs = nil
390-
newUniqueIdx.CompositeColumnIDs = nil
391-
newUniqueIdx.KeyColumnIDs = nil
392-
// Set correct version and encoding type.
393-
//
394-
// TODO(postamar): bump version to LatestIndexDescriptorVersion in 22.2
395-
// This is not possible until then because of a limitation in 21.2 which
396-
// affects mixed-21.2-22.1-version clusters (issue #78426).
397-
newUniqueIdx.Version = descpb.StrictIndexColumnIDGuaranteesVersion
398-
newUniqueIdx.EncodingType = catenumpb.SecondaryIndexEncoding
399-
if err := addIndexMutationWithSpecificPrimaryKey(ctx, tableDesc, &newUniqueIdx, newPrimaryIndexDesc, p.ExecCfg().Settings); err != nil {
400-
return err
401-
}
402-
// Copy the old zone configuration into the newly created unique index for PARTITION ALL BY.
403-
if tableDesc.IsLocalityRegionalByRow() {
404-
if err := p.configureZoneConfigForNewIndexPartitioning(
405-
ctx,
406-
tableDesc,
407-
newUniqueIdx,
408-
); err != nil {
409-
return err
410-
}
411-
}
412-
}
413-
414380
// We have to rewrite all indexes that either:
415381
// * depend on uniqueness from the old primary key (inverted, non-unique, or unique with nulls).
416382
// * don't store or index all columns in the new primary key.
@@ -539,6 +505,40 @@ func (p *planner) AlterPrimaryKey(
539505
newIndexIDs = append(newIndexIDs, newIndex.ID)
540506
}
541507

508+
// Create a new index that indexes everything the old primary index
509+
// does, but doesn't store anything.
510+
if shouldCopyPrimaryKey(tableDesc, newPrimaryIndexDesc, alterPrimaryKeyLocalitySwap) {
511+
newUniqueIdx := tableDesc.GetPrimaryIndex().IndexDescDeepCopy()
512+
// Clear the following fields so that they get generated by AllocateIDs.
513+
newUniqueIdx.ID = 0
514+
newUniqueIdx.Name = ""
515+
newUniqueIdx.StoreColumnIDs = nil
516+
newUniqueIdx.StoreColumnNames = nil
517+
newUniqueIdx.KeySuffixColumnIDs = nil
518+
newUniqueIdx.CompositeColumnIDs = nil
519+
newUniqueIdx.KeyColumnIDs = nil
520+
// Set correct version and encoding type.
521+
//
522+
// TODO(postamar): bump version to LatestIndexDescriptorVersion in 22.2
523+
// This is not possible until then because of a limitation in 21.2 which
524+
// affects mixed-21.2-22.1-version clusters (issue #78426).
525+
newUniqueIdx.Version = descpb.StrictIndexColumnIDGuaranteesVersion
526+
newUniqueIdx.EncodingType = catenumpb.SecondaryIndexEncoding
527+
if err := addIndexMutationWithSpecificPrimaryKey(ctx, tableDesc, &newUniqueIdx, newPrimaryIndexDesc, p.ExecCfg().Settings); err != nil {
528+
return err
529+
}
530+
// Copy the old zone configuration into the newly created unique index for PARTITION ALL BY.
531+
if tableDesc.IsLocalityRegionalByRow() {
532+
if err := p.configureZoneConfigForNewIndexPartitioning(
533+
ctx,
534+
tableDesc,
535+
newUniqueIdx,
536+
); err != nil {
537+
return err
538+
}
539+
}
540+
}
541+
542542
// Determine if removing this index would lead to the uniqueness for a foreign
543543
// key back reference, which will cause this swap operation to be blocked.
544544
const withSearchForReplacement = true

0 commit comments

Comments
 (0)