diff --git a/pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit b/pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit index a393cc40710b..6264da5ce540 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit +++ b/pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit @@ -599,7 +599,6 @@ CREATE TABLE public.t ( u STRING NULL, e INT8 NOT NULL, CONSTRAINT t_pkey PRIMARY KEY (pk2 ASC), - UNIQUE INDEX t_pk_key (pk ASC), UNIQUE INDEX t_u_key (u ASC), INDEX t_a_idx (a ASC), UNIQUE INDEX t_b_key (b ASC), @@ -608,6 +607,7 @@ CREATE TABLE public.t ( INDEX created_idx (c ASC), UNIQUE INDEX t_e_key (e ASC), UNIQUE INDEX unique_c_d (c ASC, d ASC), + UNIQUE INDEX t_pk_key (pk ASC), FAMILY fam_0_pk_pk2_partition_by_a_b_c_d_j_u (pk, pk2, partition_by, a, b, c, d, j, u, e) ) PARTITION ALL BY LIST (partition_by) ( PARTITION one VALUES IN ((1)), @@ -615,6 +615,7 @@ CREATE TABLE public.t ( ) -- Warning: Partitioned table with no zone configurations. + query TTB colnames SELECT index_name, column_name, implicit FROM crdb_internal.index_columns WHERE descriptor_name = 't' AND column_type = 'key' diff --git a/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row b/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row index 88dd525b7040..f75373d0ce1b 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row +++ b/pkg/ccl/logictestccl/testdata/logic_test/regional_by_row @@ -531,12 +531,12 @@ CREATE TABLE public.regional_by_row_table ( j JSONB NULL, 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, CONSTRAINT regional_by_row_table_pkey PRIMARY KEY (pk2 ASC), - UNIQUE INDEX regional_by_row_table_pk_key (pk ASC), INDEX regional_by_row_table_a_idx (a ASC), UNIQUE INDEX regional_by_row_table_b_key (b ASC), INVERTED INDEX regional_by_row_table_j_idx (j), UNIQUE INDEX uniq_idx (a ASC) WHERE b > 0:::INT8, UNIQUE INDEX unique_b_a (b ASC, a ASC), + UNIQUE INDEX regional_by_row_table_pk_key (pk ASC), FAMILY fam_0_pk_pk2_a_b_j_crdb_region (pk, pk2, a, b, j, crdb_region) ) LOCALITY REGIONAL BY ROW; 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 diff --git a/pkg/ccl/logictestccl/testdata/logic_test/zone b/pkg/ccl/logictestccl/testdata/logic_test/zone index b984674e88cb..afb44bae9a57 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/zone +++ b/pkg/ccl/logictestccl/testdata/logic_test/zone @@ -1131,7 +1131,6 @@ t CREATE TABLE public.t ( z INT8 NULL, w INT8 NULL, CONSTRAINT t_pkey PRIMARY KEY (y ASC), - UNIQUE INDEX t_x_key (x ASC), INDEX i1 (z ASC) PARTITION BY LIST (z) ( PARTITION p1 VALUES IN ((1), (2)), PARTITION p2 VALUES IN ((3), (4)) @@ -1140,6 +1139,7 @@ t CREATE TABLE public.t ( PARTITION p3 VALUES IN ((5), (6)), PARTITION p4 VALUES IN ((7), (8)) ), + UNIQUE INDEX t_x_key (x ASC), FAMILY fam_0_x_y_z_w (x, y, z, w) ); ALTER PARTITION p1 OF INDEX test.public.t@i1 CONFIGURE ZONE USING diff --git a/pkg/ccl/partitionccl/zone_test.go b/pkg/ccl/partitionccl/zone_test.go index 13f816bf39d3..572af5464e68 100644 --- a/pkg/ccl/partitionccl/zone_test.go +++ b/pkg/ccl/partitionccl/zone_test.go @@ -1026,12 +1026,12 @@ func TestPrimaryKeyChangeZoneConfigs(t *testing.T) { // Our subzones should be spans prefixed with dropped copy of i1, // dropped copy of i2, new copy of i1, and new copy of i2. - // These have ID's 2, 3, 8 and 10 respectively. + // These have ID's 2, 3, 6 and 8 respectively. expectedSpans := []roachpb.Key{ table.IndexSpan(codec, 2 /* indexID */).Key, table.IndexSpan(codec, 3 /* indexID */).Key, + table.IndexSpan(codec, 6 /* indexID */).Key, table.IndexSpan(codec, 8 /* indexID */).Key, - table.IndexSpan(codec, 10 /* indexID */).Key, } if len(zone.SubzoneSpans) != len(expectedSpans) { t.Fatalf("expected subzones to have length %d", len(expectedSpans)) diff --git a/pkg/cmd/roachtest/tests/backup.go b/pkg/cmd/roachtest/tests/backup.go index e50d467e9421..ee38e6c437ea 100644 --- a/pkg/cmd/roachtest/tests/backup.go +++ b/pkg/cmd/roachtest/tests/backup.go @@ -895,7 +895,7 @@ func registerBackup(r registry.Registry) { Leases: registry.MetamorphicLeases, EncryptionSupport: registry.EncryptionMetamorphic, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } runBackupMVCCRangeTombstones(ctx, t, c, mvccRangeTombstoneConfig{}) diff --git a/pkg/cmd/roachtest/tests/copy.go b/pkg/cmd/roachtest/tests/copy.go index 06cedc1e48f9..b8d9efcbb5c7 100644 --- a/pkg/cmd/roachtest/tests/copy.go +++ b/pkg/cmd/roachtest/tests/copy.go @@ -185,7 +185,7 @@ func registerCopy(r registry.Registry) { Cluster: r.MakeClusterSpec(tc.nodes), Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } runCopy(ctx, t, c, tc.rows, tc.txn) diff --git a/pkg/cmd/roachtest/tests/import.go b/pkg/cmd/roachtest/tests/import.go index 13529111a300..bf7bb5082b43 100644 --- a/pkg/cmd/roachtest/tests/import.go +++ b/pkg/cmd/roachtest/tests/import.go @@ -92,7 +92,7 @@ func registerImportNodeShutdown(r registry.Registry) { Cluster: r.MakeClusterSpec(4), Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } c.Put(ctx, t.Cockroach(), "./cockroach") @@ -110,7 +110,7 @@ func registerImportNodeShutdown(r registry.Registry) { Cluster: r.MakeClusterSpec(4), Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } c.Put(ctx, t.Cockroach(), "./cockroach") @@ -227,7 +227,7 @@ func registerImportTPCH(r registry.Registry) { EncryptionSupport: registry.EncryptionMetamorphic, Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } tick, perfBuf := initBulkJobPerfArtifacts(t.Name(), item.timeout) diff --git a/pkg/cmd/roachtest/tests/import_cancellation.go b/pkg/cmd/roachtest/tests/import_cancellation.go index daeec7360d66..eda0010106c8 100644 --- a/pkg/cmd/roachtest/tests/import_cancellation.go +++ b/pkg/cmd/roachtest/tests/import_cancellation.go @@ -37,7 +37,7 @@ func registerImportCancellation(r registry.Registry) { Cluster: r.MakeClusterSpec(6, spec.CPU(32)), Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } runImportCancellation(ctx, t, c) diff --git a/pkg/cmd/roachtest/tests/mixed_version_backup.go b/pkg/cmd/roachtest/tests/mixed_version_backup.go index 3b5d762d20ed..dfec23af861e 100644 --- a/pkg/cmd/roachtest/tests/mixed_version_backup.go +++ b/pkg/cmd/roachtest/tests/mixed_version_backup.go @@ -2122,7 +2122,7 @@ func registerBackupMixedVersion(r registry.Registry) { EncryptionSupport: registry.EncryptionMetamorphic, RequiresLicense: true, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroachdb-backup-testing; see https://github.com/cockroachdb/cockroach/issues/105968") } diff --git a/pkg/cmd/roachtest/tests/mixed_version_decl_schemachange_compat.go b/pkg/cmd/roachtest/tests/mixed_version_decl_schemachange_compat.go index 4c0d189e3235..82098c52ac21 100644 --- a/pkg/cmd/roachtest/tests/mixed_version_decl_schemachange_compat.go +++ b/pkg/cmd/roachtest/tests/mixed_version_decl_schemachange_compat.go @@ -32,7 +32,7 @@ func registerDeclSchemaChangeCompatMixedVersions(r registry.Registry) { Owner: registry.OwnerSQLFoundations, Cluster: r.MakeClusterSpec(1), Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-corpus; see https://github.com/cockroachdb/cockroach/issues/105968") } runDeclSchemaChangeCompatMixedVersions(ctx, t, c, t.BuildVersion()) diff --git a/pkg/cmd/roachtest/tests/schemachange.go b/pkg/cmd/roachtest/tests/schemachange.go index 6069c5cb223f..a5a02f5c2aa1 100644 --- a/pkg/cmd/roachtest/tests/schemachange.go +++ b/pkg/cmd/roachtest/tests/schemachange.go @@ -34,7 +34,7 @@ func registerSchemaChangeDuringKV(r registry.Registry) { Cluster: r.MakeClusterSpec(5), Leases: registry.MetamorphicLeases, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } const fixturePath = `gs://cockroach-fixtures/workload/tpch/scalefactor=10/backup?AUTH=implicit` diff --git a/pkg/cmd/roachtest/tests/sqlsmith.go b/pkg/cmd/roachtest/tests/sqlsmith.go index 5f4886ed2b22..5cead1ecd439 100644 --- a/pkg/cmd/roachtest/tests/sqlsmith.go +++ b/pkg/cmd/roachtest/tests/sqlsmith.go @@ -317,7 +317,7 @@ WITH into_db = 'defaultdb', unsafe_restore_incompatible_version; // NB: sqlsmith failures should never block a release. NonReleaseBlocker: true, Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } runSQLSmith(ctx, t, c, setup, setting) diff --git a/pkg/cmd/roachtest/tests/tpc_utils.go b/pkg/cmd/roachtest/tests/tpc_utils.go index ebf613d10f48..f6a6b18120b8 100644 --- a/pkg/cmd/roachtest/tests/tpc_utils.go +++ b/pkg/cmd/roachtest/tests/tpc_utils.go @@ -44,7 +44,7 @@ func loadTPCHDataset( disableMergeQueue bool, secure bool, ) (retErr error) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } diff --git a/pkg/cmd/roachtest/tests/tpcdsvec.go b/pkg/cmd/roachtest/tests/tpcdsvec.go index 960b43388211..432bca398227 100644 --- a/pkg/cmd/roachtest/tests/tpcdsvec.go +++ b/pkg/cmd/roachtest/tests/tpcdsvec.go @@ -191,7 +191,7 @@ WITH unsafe_restore_incompatible_version; Benchmark: true, Cluster: r.MakeClusterSpec(3), Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - if c.Spec().Cloud != spec.GCE { + if c.Spec().Cloud != spec.GCE && !c.IsLocal() { t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968") } runTPCDSVec(ctx, t, c) diff --git a/pkg/sql/alter_primary_key.go b/pkg/sql/alter_primary_key.go index f9478029c7f4..9078efbc0031 100644 --- a/pkg/sql/alter_primary_key.go +++ b/pkg/sql/alter_primary_key.go @@ -377,40 +377,6 @@ func (p *planner) AlterPrimaryKey( ) } - // Create a new index that indexes everything the old primary index - // does, but doesn't store anything. - if shouldCopyPrimaryKey(tableDesc, newPrimaryIndexDesc, alterPrimaryKeyLocalitySwap) { - newUniqueIdx := tableDesc.GetPrimaryIndex().IndexDescDeepCopy() - // Clear the following fields so that they get generated by AllocateIDs. - newUniqueIdx.ID = 0 - newUniqueIdx.Name = "" - newUniqueIdx.StoreColumnIDs = nil - newUniqueIdx.StoreColumnNames = nil - newUniqueIdx.KeySuffixColumnIDs = nil - newUniqueIdx.CompositeColumnIDs = nil - newUniqueIdx.KeyColumnIDs = nil - // Set correct version and encoding type. - // - // TODO(postamar): bump version to LatestIndexDescriptorVersion in 22.2 - // This is not possible until then because of a limitation in 21.2 which - // affects mixed-21.2-22.1-version clusters (issue #78426). - newUniqueIdx.Version = descpb.StrictIndexColumnIDGuaranteesVersion - newUniqueIdx.EncodingType = catenumpb.SecondaryIndexEncoding - if err := addIndexMutationWithSpecificPrimaryKey(ctx, tableDesc, &newUniqueIdx, newPrimaryIndexDesc, p.ExecCfg().Settings); err != nil { - return err - } - // Copy the old zone configuration into the newly created unique index for PARTITION ALL BY. - if tableDesc.IsLocalityRegionalByRow() { - if err := p.configureZoneConfigForNewIndexPartitioning( - ctx, - tableDesc, - newUniqueIdx, - ); err != nil { - return err - } - } - } - // We have to rewrite all indexes that either: // * depend on uniqueness from the old primary key (inverted, non-unique, or unique with nulls). // * don't store or index all columns in the new primary key. @@ -539,6 +505,40 @@ func (p *planner) AlterPrimaryKey( newIndexIDs = append(newIndexIDs, newIndex.ID) } + // Create a new index that indexes everything the old primary index + // does, but doesn't store anything. + if shouldCopyPrimaryKey(tableDesc, newPrimaryIndexDesc, alterPrimaryKeyLocalitySwap) { + newUniqueIdx := tableDesc.GetPrimaryIndex().IndexDescDeepCopy() + // Clear the following fields so that they get generated by AllocateIDs. + newUniqueIdx.ID = 0 + newUniqueIdx.Name = "" + newUniqueIdx.StoreColumnIDs = nil + newUniqueIdx.StoreColumnNames = nil + newUniqueIdx.KeySuffixColumnIDs = nil + newUniqueIdx.CompositeColumnIDs = nil + newUniqueIdx.KeyColumnIDs = nil + // Set correct version and encoding type. + // + // TODO(postamar): bump version to LatestIndexDescriptorVersion in 22.2 + // This is not possible until then because of a limitation in 21.2 which + // affects mixed-21.2-22.1-version clusters (issue #78426). + newUniqueIdx.Version = descpb.StrictIndexColumnIDGuaranteesVersion + newUniqueIdx.EncodingType = catenumpb.SecondaryIndexEncoding + if err := addIndexMutationWithSpecificPrimaryKey(ctx, tableDesc, &newUniqueIdx, newPrimaryIndexDesc, p.ExecCfg().Settings); err != nil { + return err + } + // Copy the old zone configuration into the newly created unique index for PARTITION ALL BY. + if tableDesc.IsLocalityRegionalByRow() { + if err := p.configureZoneConfigForNewIndexPartitioning( + ctx, + tableDesc, + newUniqueIdx, + ); err != nil { + return err + } + } + } + // Determine if removing this index would lead to the uniqueness for a foreign // key back reference, which will cause this swap operation to be blocked. const withSearchForReplacement = true diff --git a/pkg/sql/logictest/testdata/logic_test/alter_primary_key b/pkg/sql/logictest/testdata/logic_test/alter_primary_key index 4075686c7a4d..a6a6838a24bc 100644 --- a/pkg/sql/logictest/testdata/logic_test/alter_primary_key +++ b/pkg/sql/logictest/testdata/logic_test/alter_primary_key @@ -269,13 +269,13 @@ t CREATE TABLE public.t ( crdb_internal_z_shard_4 INT8 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(z)), 4:::INT8)) VIRTUAL, CONSTRAINT t_pkey PRIMARY KEY (y ASC), UNIQUE INDEX i3 (z ASC) STORING (y), - UNIQUE INDEX t_x_key (x ASC), INDEX i1 (w ASC), INDEX i2 (y ASC), UNIQUE INDEX i4 (z ASC), UNIQUE INDEX i5 (w ASC) STORING (y), INVERTED INDEX i6 (v), INDEX i7 (z ASC) USING HASH WITH (bucket_count=4), + UNIQUE INDEX t_x_key (x ASC), FAMILY fam_0_x_y_z_w_v (x, y, z, w, v) ) @@ -287,13 +287,13 @@ SELECT index_id, index_name FROM crdb_internal.table_indexes WHERE descriptor_na ---- 4 i3 9 t_pkey -11 t_x_key -13 i1 -15 i2 -17 i4 -19 i5 -21 i6 -23 i7 +11 i1 +13 i2 +15 i4 +17 i5 +19 i6 +21 i7 +23 t_x_key # Make sure that each index can index join against the new primary key; @@ -429,8 +429,8 @@ t CREATE TABLE public.t ( crdb_internal_z_shard_5 INT8 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(z)), 5:::INT8)) VIRTUAL, crdb_internal_y_shard_10 INT8 NOT VISIBLE NOT NULL AS (mod(fnv32(crdb_internal.datums_to_bytes(y)), 10:::INT8)) VIRTUAL, CONSTRAINT t_pkey PRIMARY KEY (y ASC) USING HASH WITH (bucket_count=10), - UNIQUE INDEX t_x_key (x ASC), INDEX i1 (z ASC) USING HASH WITH (bucket_count=5), + UNIQUE INDEX t_x_key (x ASC), FAMILY fam_0_x_y_z (x, y, z) ) @@ -448,8 +448,8 @@ query IT SELECT index_id, index_name FROM crdb_internal.table_indexes WHERE descriptor_name = 't' ORDER BY index_id ---- 3 t_pkey -5 t_x_key -7 i1 +5 i1 +7 t_x_key query III SELECT * FROM t@t_pkey @@ -494,8 +494,8 @@ t CREATE TABLE public.t ( y INT8 NOT NULL, z INT8 NULL, CONSTRAINT t_pkey PRIMARY KEY (y ASC), - UNIQUE INDEX t_x_key (x ASC) USING HASH WITH (bucket_count=5), INDEX i (z ASC), + UNIQUE INDEX t_x_key (x ASC) USING HASH WITH (bucket_count=5), FAMILY fam_0_x_y_z (x, y, z) ) @@ -1397,23 +1397,6 @@ a b k statement ok ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (k); -# Legacy schema changer and declarative schema changer will produce slightly -# different secondary index ordering for alter primary key, hence we assert -# separately with slightly different expected output. -onlyif config local-legacy-schema-changer -query T -SELECT create_statement FROM [SHOW CREATE TABLE t]; ----- -CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC) -) - -skipif config local-legacy-schema-changer query T SELECT create_statement FROM [SHOW CREATE TABLE t]; ---- @@ -1450,24 +1433,6 @@ a b k statement ok ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (b, k); -# Legacy schema changer and declarative schema changer will produce slightly -# different secondary index ordering for alter primary key, hence we assert -# separately with slightly different expected output. -onlyif config local-legacy-schema-changer -query T -SELECT create_statement FROM [SHOW CREATE TABLE t]; ----- -CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (b ASC, k ASC), - UNIQUE INDEX t_k_key (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC) -) - -skipif config local-legacy-schema-changer query T SELECT create_statement FROM [SHOW CREATE TABLE t]; ---- @@ -1512,25 +1477,6 @@ a b k statement ok ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a); -# Legacy schema changer and declarative schema changer will produce slightly -# different secondary index ordering for alter primary key, hence we assert -# separately with slightly different expected output. -onlyif config local-legacy-schema-changer -query T -SELECT create_statement FROM [SHOW CREATE TABLE t]; ----- -CREATE TABLE public.t ( - a INT8 NOT NULL, - b INT8 NOT NULL, - k INT8 NOT NULL AS (a + b) VIRTUAL, - CONSTRAINT t_pkey PRIMARY KEY (a ASC), - UNIQUE INDEX t_b_k_key (b ASC, k ASC), - UNIQUE INDEX t_k_key (k ASC), - UNIQUE INDEX t_a_key (a ASC), - INDEX t_idx_b_k (b ASC, k ASC) -) - -skipif config local-legacy-schema-changer query T SELECT create_statement FROM [SHOW CREATE TABLE t]; ---- @@ -1950,22 +1896,6 @@ CREATE TABLE t_99303 (i INT NOT NULL PRIMARY KEY, j INT NOT NULL, UNIQUE INDEX ( statement ok ALTER TABLE t_99303 ALTER PRIMARY KEY USING COLUMNS (j); -# Legacy schema changer and declarative schema changer will produce slightly -# different secondary index ordering for alter primary key, hence we assert -# separately with slightly different expected output. -onlyif config local-legacy-schema-changer -query TT -SHOW CREATE t_99303 ----- -t_99303 CREATE TABLE public.t_99303 ( - i INT8 NOT NULL, - j INT8 NOT NULL, - CONSTRAINT t_99303_pkey PRIMARY KEY (j ASC), - UNIQUE INDEX t_99303_i_key1 (i ASC), - UNIQUE INDEX t_99303_i_key (i ASC) WHERE i > 0:::INT8 - ) - -skipif config local-legacy-schema-changer query TT SHOW CREATE t_99303 ---- diff --git a/pkg/sql/schema_changer_test.go b/pkg/sql/schema_changer_test.go index 1ed2cca376e9..be830665ae1d 100644 --- a/pkg/sql/schema_changer_test.go +++ b/pkg/sql/schema_changer_test.go @@ -2257,8 +2257,8 @@ INSERT INTO t.test VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3); y INT8 NOT NULL, z INT8 NULL, CONSTRAINT test_pkey PRIMARY KEY (y ASC), - UNIQUE INDEX test_x_key (x ASC), - INDEX i (z ASC) + INDEX i (z ASC), + UNIQUE INDEX test_x_key (x ASC) )` if create != expected { t.Fatalf("expected %s, found %s", expected, create) diff --git a/pkg/storage/engine_key_test.go b/pkg/storage/engine_key_test.go index 736c86e4d3a2..9f705d96ea79 100644 --- a/pkg/storage/engine_key_test.go +++ b/pkg/storage/engine_key_test.go @@ -288,7 +288,7 @@ func TestEngineKeyValidate(t *testing.T) { if err := ek.Validate(); err != nil { t.Errorf("%q.Validate() = %q, want nil", ek, err) } - require.Equal(t, 0.0, testing.AllocsPerRun(1, func() { + require.Equal(t, 0.0, testing.AllocsPerRun(1000, func() { _ = ek.Validate() })) } @@ -301,7 +301,7 @@ func TestEngineKeyValidate(t *testing.T) { if err := ek.Validate(); err != nil { t.Errorf("%q.Validate() = %q, want nil", ek, err) } - require.Equal(t, 0.0, testing.AllocsPerRun(1, func() { + require.Equal(t, 0.0, testing.AllocsPerRun(1000, func() { _ = ek.Validate() })) buf = ek.Key[:0] diff --git a/pkg/upgrade/upgradecluster/tenant_cluster.go b/pkg/upgrade/upgradecluster/tenant_cluster.go index d86925bfa934..1310ea031d7f 100644 --- a/pkg/upgrade/upgradecluster/tenant_cluster.go +++ b/pkg/upgrade/upgradecluster/tenant_cluster.go @@ -29,6 +29,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/retry" "github.com/cockroachdb/errors" "github.com/cockroachdb/redact" + "google.golang.org/grpc" ) // TenantCluster represents the set of sql nodes running in a secondary tenant. @@ -228,8 +229,19 @@ func (t *TenantCluster) ForEveryNodeOrServer( grp.GoCtx(func(ctx context.Context) error { defer alloc.Release() - conn, err := t.Dialer.Dial(ctx, roachpb.NodeID(instance.InstanceID), rpc.DefaultClass) - if err != nil { + var conn *grpc.ClientConn + retryOpts := retry.Options{ + InitialBackoff: 0, + MaxRetries: 2, + MaxBackoff: 10 * time.Millisecond, + } + // This retry was added to benefit our tests (not users) by reducing the chance of + // test flakes due to network issues. + if err := retry.WithMaxAttempts(ctx, retryOpts, retryOpts.MaxRetries+1, func() error { + var err error + conn, err = t.Dialer.Dial(ctx, roachpb.NodeID(instance.InstanceID), rpc.DefaultClass) + return err + }); err != nil { if errors.HasType(err, (*netutil.InitialHeartbeatFailedError)(nil)) { if errors.Is(err, rpc.VersionCompatError) { return errors.WithHint(errors.Newf("upgrade failed due to active SQL servers with incompatible binary version(s)"),