Skip to content

Commit 1f8fa96

Browse files
craig[bot]itsbilalyuzefovichknzRui Hu
committed
107297: storage,kvserver: Foundational changes for disaggregated ingestions r=sumeerbhola a=itsbilal This change contains two commits (split off from the original mega-PR, cockroachdb#105839). The first is a pkg/storage change to add new interface methods to call pebble's db.ScanInternal as well as implement related helper methods in sstable writers/batch readers/writers to be able to do disaggregated snapshot ingestion. The second is a kvserver/rditer change to allow finer-grained control on what replicated spans we iterate on, as well as to be able to specifically opt into skip-shared iteration over the user key span through the use of `ScanInternal`. --- **storage: Update Engine/Reader/Writer interfaces for ScanInternal** This change updates pkg/storage interfaces and implementations to allow the use of ScanInternal in skip-shared iteration mode as well as writing/reading of internal point keys, range dels and range keys. Replication / snapshot code will soon rely on these changes to be able to replicate internal keys in higher levels plus metadata of shared sstables in lower levels, as opposed to just observed user keys. Part of cockroachdb#103028 Epic: none Release note: None **kvserver: Add ability to filter replicated spans in Select/Iterate** This change adds the ability to select for just the replicated span in rditer.Select and rditer.IterateReplicaKeySpans. Also adds a new rditer.IterateReplicaKeySpansShared that does a ScanInternal on just the user key span, to be able to collect metadata of shared sstables as well as any internal keys above them. We only use skip-shared iteration for the replicated user key span of a range, and in practice, only if it's a non-system range. Part of cockroachdb#103028. Epic: none Release note: None 108336: sql: retry more distributed errors as local r=yuzefovich a=yuzefovich This PR contains a couple of commits that increase the allow-list of errors that are retried locally. In particular, it allows us to hide some issues we have around using DistSQL and shutting down SQL pods. Fixes: cockroachdb#106537. Fixes: cockroachdb#108152. Fixes: cockroachdb#108271. Release note: None 108406: server,testutils: remove complexity r=yuzefovich,herkolategan a=knz There is a saying (paraphrasing) that it always takes more work removing unwanted complexity than it takes to add it. This is an example of that. Prior to this commit, there was an "interesting" propagation of the flag that decides whether or not to define a test tenant for test servers and clusters. In a nutshell, we had: - an "input" flag in `base.TestServerArgs`, which remained mostly immutable - a boolean decided once by `ShouldStartDefaultTestTenant()` either in: - `serverutils.StartServerOnlyE` - or `testcluster.Start` - that boolean choice was then propagated to `server.testServer` via _another_ boolean config flag in `server.BaseConfig` - both the 2nd boolean and the original input flag were then again checked when the time came to do the work (in `maybeStartDefaultTestTenant`). Additional complexity was then incurred by the need of `TestCluster` to make the determination just once (and not once per server). This commit cuts through all the layers of complexity by simply propagating the choice of `ShouldStartDefaultTestTenant()` back into the `TestServerArgs` and only ever reading from that subsequently. Release note: None Epic: CRDB-18499 108465: cloudccl: allow external connection tests to be run in parallel r=rhu713 a=rhu713 Currently external connection tests read and write to the same path in cloud storage. Add a random uint64 as part of the path so that test runs have unique paths and can be run in parallel. Fixes: cockroachdb#107407 Release note: None 108481: acceptance: stabilize start-single-node in tcl test r=santamaura a=dhartunian We've continued to see flakes on this test which contain messages of throttled stores on node startup. The hypothesis is that these are due to leftover data directories from prior startups during the same test. This change clears the `logs/db` data directory for those invocations and also adds the sql memory flag which the common tcl function also uses. Resolves cockroachdb#108405 Epic: None Release note: None 108496: kv: unit test `PrepareTransactionForRetry` and `TransactionRefreshTimestamp` r=miraradeva a=nvanbenschoten Informs cockroachdb#104233. This commit adds a pair of new unit tests to verify the behavior of `PrepareTransactionForRetry` and `TransactionRefreshTimestamp`. These functions will be getting more complex for cockroachdb#104233, so it will be helpful to have these tests in place. The tests also serve as good documentation. Release note: None Co-authored-by: Bilal Akhtar <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Rui Hu <[email protected]> Co-authored-by: David Hartunian <[email protected]> Co-authored-by: Nathan VanBenschoten <[email protected]>
7 parents eff0185 + e714d52 + 5c09eb1 + 49374d4 + 38f086c + 64d2b3f + a4005e3 commit 1f8fa96

File tree

76 files changed

+1302
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1302
-294
lines changed

pkg/base/test_server_args.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ var (
281281

282282
// InternalNonDefaultDecision is a sentinel value used inside a
283283
// mechanism in serverutils. Should not be used by tests directly.
284-
//
285-
// TODO(#76378): Investigate how we can remove the need for this
286-
// sentinel value.
287284
InternalNonDefaultDecision = DefaultTestTenantOptions{testBehavior: ttDisabled, allowAdditionalTenants: true}
288285
)
289286

pkg/ccl/backupccl/backup_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ func TestBackupRestorePartitioned(t *testing.T) {
337337

338338
// Disabled to run within tenant as certain MR features are not available to tenants.
339339
args := base.TestClusterArgs{
340+
ServerArgs: base.TestServerArgs{
341+
DefaultTestTenant: base.TODOTestTenantDisabled,
342+
},
340343
ServerArgsPerNode: map[int]base.TestServerArgs{
341344
0: {
342-
DefaultTestTenant: base.TODOTestTenantDisabled,
343345
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
344346
{Key: "region", Value: "west"},
345347
// NB: This has the same value as an az in the east region
@@ -349,7 +351,6 @@ func TestBackupRestorePartitioned(t *testing.T) {
349351
}},
350352
},
351353
1: {
352-
DefaultTestTenant: base.TODOTestTenantDisabled,
353354
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
354355
{Key: "region", Value: "east"},
355356
// NB: This has the same value as an az in the west region
@@ -359,7 +360,6 @@ func TestBackupRestorePartitioned(t *testing.T) {
359360
}},
360361
},
361362
2: {
362-
DefaultTestTenant: base.TODOTestTenantDisabled,
363363
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
364364
{Key: "region", Value: "east"},
365365
{Key: "az", Value: "az2"},
@@ -490,34 +490,33 @@ func TestBackupRestoreExecLocality(t *testing.T) {
490490

491491
// Disabled to run within tenant as certain MR features are not available to tenants.
492492
args := base.TestClusterArgs{
493+
ServerArgs: base.TestServerArgs{
494+
DefaultTestTenant: base.TODOTestTenantDisabled,
495+
},
493496
ServerArgsPerNode: map[int]base.TestServerArgs{
494497
0: {
495-
ExternalIODir: "/west0",
496-
DefaultTestTenant: base.TODOTestTenantDisabled,
498+
ExternalIODir: "/west0",
497499
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
498500
{Key: "tier", Value: "0"},
499501
{Key: "region", Value: "west"},
500502
}},
501503
},
502504
1: {
503-
ExternalIODir: "/west1",
504-
DefaultTestTenant: base.TODOTestTenantDisabled,
505+
ExternalIODir: "/west1",
505506
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
506507
{Key: "tier", Value: "1"},
507508
{Key: "region", Value: "west"},
508509
}},
509510
},
510511
2: {
511-
ExternalIODir: "/east0",
512-
DefaultTestTenant: base.TODOTestTenantDisabled,
512+
ExternalIODir: "/east0",
513513
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
514514
{Key: "tier", Value: "0"},
515515
{Key: "region", Value: "east"},
516516
}},
517517
},
518518
3: {
519-
ExternalIODir: "/east1",
520-
DefaultTestTenant: base.TODOTestTenantDisabled,
519+
ExternalIODir: "/east1",
521520
Locality: roachpb.Locality{Tiers: []roachpb.Tier{
522521
{Key: "tier", Value: "1"},
523522
{Key: "region", Value: "east"},

pkg/ccl/changefeedccl/changefeed_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5689,10 +5689,7 @@ func TestChangefeedHandlesRollingRestart(t *testing.T) {
56895689
nodeDrainChannels[n].Store(make(chan struct{}))
56905690

56915691
return base.TestServerArgs{
5692-
// Test uses SPLIT AT, which isn't currently supported for
5693-
// secondary tenants. Tracked with #76378.
5694-
DefaultTestTenant: base.TODOTestTenantDisabled,
5695-
UseDatabase: "test",
5692+
UseDatabase: "test",
56965693
Knobs: base.TestingKnobs{
56975694
DistSQL: &execinfra.TestingKnobs{
56985695
DrainFast: true,
@@ -5770,6 +5767,11 @@ func TestChangefeedHandlesRollingRestart(t *testing.T) {
57705767
}
57715768
return perNode
57725769
}(),
5770+
ServerArgs: base.TestServerArgs{
5771+
// Test uses SPLIT AT, which isn't currently supported for
5772+
// secondary tenants. Tracked with #76378.
5773+
DefaultTestTenant: base.TODOTestTenantDisabled,
5774+
},
57735775
})
57745776
defer tc.Stopper().Stop(context.Background())
57755777

@@ -5882,9 +5884,6 @@ func TestChangefeedPropagatesTerminalError(t *testing.T) {
58825884
perServerKnobs := make(map[int]base.TestServerArgs, numNodes)
58835885
for i := 0; i < numNodes; i++ {
58845886
perServerKnobs[i] = base.TestServerArgs{
5885-
// Test uses SPLIT AT, which isn't currently supported for
5886-
// secondary tenants. Tracked with #76378.
5887-
DefaultTestTenant: base.TODOTestTenantDisabled,
58885887
Knobs: base.TestingKnobs{
58895888
DistSQL: &execinfra.TestingKnobs{
58905889
DrainFast: true,
@@ -5901,6 +5900,11 @@ func TestChangefeedPropagatesTerminalError(t *testing.T) {
59015900
base.TestClusterArgs{
59025901
ServerArgsPerNode: perServerKnobs,
59035902
ReplicationMode: base.ReplicationManual,
5903+
ServerArgs: base.TestServerArgs{
5904+
// Test uses SPLIT AT, which isn't currently supported for
5905+
// secondary tenants. Tracked with #76378.
5906+
DefaultTestTenant: base.TODOTestTenantDisabled,
5907+
},
59045908
})
59055909
defer tc.Stopper().Stop(context.Background())
59065910

@@ -8241,13 +8245,17 @@ func TestChangefeedExecLocality(t *testing.T) {
82418245
str := strconv.Itoa
82428246

82438247
const nodes = 4
8244-
args := base.TestClusterArgs{ServerArgsPerNode: map[int]base.TestServerArgs{}}
8248+
args := base.TestClusterArgs{
8249+
ServerArgs: base.TestServerArgs{
8250+
DefaultTestTenant: base.TODOTestTenantDisabled, // need nodelocal and splits.
8251+
},
8252+
ServerArgsPerNode: map[int]base.TestServerArgs{},
8253+
}
82458254
for i := 0; i < nodes; i++ {
82468255
args.ServerArgsPerNode[i] = base.TestServerArgs{
82478256
ExternalIODir: path.Join(dir, str(i)),
82488257
Locality: roachpb.Locality{
82498258
Tiers: []roachpb.Tier{{Key: "x", Value: str(i / 2)}, {Key: "y", Value: str(i % 2)}}},
8250-
DefaultTestTenant: base.TODOTestTenantDisabled, // need nodelocal and splits.
82518259
}
82528260
}
82538261

pkg/ccl/cloudccl/amazon/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ go_test(
1414
"//pkg/cloud",
1515
"//pkg/cloud/amazon",
1616
"//pkg/cloud/cloudpb",
17+
"//pkg/cloud/cloudtestutils",
1718
"//pkg/cloud/externalconn/providers",
1819
"//pkg/security/securityassets",
1920
"//pkg/security/securitytest",

pkg/ccl/cloudccl/amazon/s3_connection_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/cloud"
2323
"github.com/cockroachdb/cockroach/pkg/cloud/amazon"
2424
"github.com/cockroachdb/cockroach/pkg/cloud/cloudpb"
25+
"github.com/cockroachdb/cockroach/pkg/cloud/cloudtestutils"
2526
_ "github.com/cockroachdb/cockroach/pkg/cloud/externalconn/providers" // import External Connection providers.
2627
"github.com/cockroachdb/cockroach/pkg/testutils"
2728
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
@@ -77,6 +78,8 @@ func TestS3ExternalConnection(t *testing.T) {
7778
skip.IgnoreLint(t, "AWS_S3_BUCKET env var must be set")
7879
}
7980

81+
testID := cloudtestutils.NewTestID()
82+
8083
t.Run("auth-implicit", func(t *testing.T) {
8184
// You can create an IAM that can access S3
8285
// in the AWS console, then set it up locally.
@@ -93,14 +96,14 @@ func TestS3ExternalConnection(t *testing.T) {
9396
params := make(url.Values)
9497
params.Add(cloud.AuthParam, cloud.AuthParamImplicit)
9598

96-
s3URI := fmt.Sprintf("s3://%s/backup-ec-test-default?%s", bucket, params.Encode())
99+
s3URI := fmt.Sprintf("s3://%s/backup-ec-test-default-%d?%s", bucket, testID, params.Encode())
97100
ecName := "auth-implicit-s3"
98101
createExternalConnection(ecName, s3URI)
99102
backupAndRestoreFromExternalConnection(ecName)
100103
})
101104

102105
t.Run("auth-specified", func(t *testing.T) {
103-
s3URI := amazon.S3URI(bucket, "backup-ec-test-default",
106+
s3URI := amazon.S3URI(bucket, fmt.Sprintf("backup-ec-test-default-%d", testID),
104107
&cloudpb.ExternalStorage_S3{
105108
AccessKey: creds.AccessKeyID,
106109
Secret: creds.SecretAccessKey,
@@ -126,7 +129,7 @@ func TestS3ExternalConnection(t *testing.T) {
126129
"refer to https://docs.aws.com/cli/latest/userguide/cli-configure-role.html: %s", err)
127130
}
128131

129-
s3URI := amazon.S3URI(bucket, "backup-ec-test-sse-256", &cloudpb.ExternalStorage_S3{
132+
s3URI := amazon.S3URI(bucket, fmt.Sprintf("backup-ec-test-sse-256-%d", testID), &cloudpb.ExternalStorage_S3{
130133
Region: "us-east-1",
131134
Auth: cloud.AuthParamImplicit,
132135
ServerEncMode: "AES256",
@@ -139,7 +142,7 @@ func TestS3ExternalConnection(t *testing.T) {
139142
if v == "" {
140143
skip.IgnoreLint(t, "AWS_KMS_KEY_ARN env var must be set")
141144
}
142-
s3KMSURI := amazon.S3URI(bucket, "backup-ec-test-sse-kms", &cloudpb.ExternalStorage_S3{
145+
s3KMSURI := amazon.S3URI(bucket, fmt.Sprintf("backup-ec-test-sse-kms-%d", testID), &cloudpb.ExternalStorage_S3{
143146
Region: "us-east-1",
144147
Auth: cloud.AuthParamImplicit,
145148
ServerEncMode: "aws:kms",
@@ -163,7 +166,7 @@ func TestS3ExternalConnection(t *testing.T) {
163166
}
164167

165168
// Unsupported server side encryption option.
166-
invalidS3URI := amazon.S3URI(bucket, "backup-ec-test-sse-256", &cloudpb.ExternalStorage_S3{
169+
invalidS3URI := amazon.S3URI(bucket, fmt.Sprintf("backup-ec-test-sse-256-%d", testID), &cloudpb.ExternalStorage_S3{
167170
Region: "us-east-1",
168171
Auth: cloud.AuthParamImplicit,
169172
ServerEncMode: "unsupported-algorithm",
@@ -172,7 +175,7 @@ func TestS3ExternalConnection(t *testing.T) {
172175
"unsupported server encryption mode unsupported-algorithm. Supported values are `aws:kms` and `AES256",
173176
fmt.Sprintf(`BACKUP DATABASE foo INTO '%s'`, invalidS3URI))
174177

175-
invalidS3URI = amazon.S3URI(bucket, "backup-ec-test-sse-256", &cloudpb.ExternalStorage_S3{
178+
invalidS3URI = amazon.S3URI(bucket, fmt.Sprintf("backup-ec-test-sse-256-%d", testID), &cloudpb.ExternalStorage_S3{
176179
Region: "us-east-1",
177180
Auth: cloud.AuthParamImplicit,
178181
ServerEncMode: "aws:kms",
@@ -257,8 +260,9 @@ func TestAWSKMSExternalConnection(t *testing.T) {
257260
skip.IgnoreLint(t, "AWS_S3_BUCKET env var must be set")
258261
}
259262

263+
testID := cloudtestutils.NewTestID()
260264
// Create an external connection where we will write the backup.
261-
backupURI := fmt.Sprintf("s3://%s/backup?%s=%s", bucket,
265+
backupURI := fmt.Sprintf("s3://%s/backup-%d?%s=%s", bucket, testID,
262266
cloud.AuthParam, cloud.AuthParamImplicit)
263267
backupExternalConnectionName := "backup"
264268
createExternalConnection(backupExternalConnectionName, backupURI)
@@ -372,8 +376,9 @@ func TestAWSKMSExternalConnectionAssumeRole(t *testing.T) {
372376
skip.IgnoreLint(t, "AWS_S3_BUCKET env var must be set")
373377
}
374378

379+
testID := cloudtestutils.NewTestID()
375380
// Create an external connection where we will write the backup.
376-
backupURI := fmt.Sprintf("s3://%s/backup?%s=%s", bucket,
381+
backupURI := fmt.Sprintf("s3://%s/backup-%d?%s=%s", bucket, testID,
377382
cloud.AuthParam, cloud.AuthParamImplicit)
378383
backupExternalConnectionName := "backup"
379384
createExternalConnection(backupExternalConnectionName, backupURI)

pkg/ccl/cloudccl/azure/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ go_test(
1313
"//pkg/ccl",
1414
"//pkg/ccl/kvccl/kvtenantccl",
1515
"//pkg/cloud/azure",
16+
"//pkg/cloud/cloudtestutils",
1617
"//pkg/cloud/externalconn/providers",
1718
"//pkg/security/securityassets",
1819
"//pkg/security/securitytest",

pkg/ccl/cloudccl/azure/azure_connection_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/cockroachdb/cockroach/pkg/base"
2121
_ "github.com/cockroachdb/cockroach/pkg/ccl"
2222
"github.com/cockroachdb/cockroach/pkg/cloud/azure"
23+
"github.com/cockroachdb/cockroach/pkg/cloud/cloudtestutils"
2324
_ "github.com/cockroachdb/cockroach/pkg/cloud/externalconn/providers" // import External Connection providers.
2425
"github.com/cockroachdb/cockroach/pkg/testutils"
2526
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
@@ -29,9 +30,9 @@ import (
2930
"github.com/cockroachdb/cockroach/pkg/util/log"
3031
)
3132

32-
func (a azureConfig) URI(file string) string {
33-
return fmt.Sprintf("azure-storage://%s/%s?%s=%s&%s=%s&%s=%s",
34-
a.bucket, file,
33+
func (a azureConfig) URI(file string, testID uint64) string {
34+
return fmt.Sprintf("azure-storage://%s/%s-%d?%s=%s&%s=%s&%s=%s",
35+
a.bucket, file, testID,
3536
azure.AzureAccountKeyParam, url.QueryEscape(a.key),
3637
azure.AzureAccountNameParam, url.QueryEscape(a.account),
3738
azure.AzureEnvironmentKeyParam, url.QueryEscape(a.environment))
@@ -97,7 +98,8 @@ func TestExternalConnections(t *testing.T) {
9798
return
9899
}
99100

101+
testID := cloudtestutils.NewTestID()
100102
ecName := "azure-ec"
101-
createExternalConnection(ecName, cfg.URI("backup-ec"))
103+
createExternalConnection(ecName, cfg.URI("backup-ec", testID))
102104
backupAndRestoreFromExternalConnection(ecName)
103105
}

0 commit comments

Comments
 (0)