Skip to content

Commit 0742137

Browse files
craig[bot]stevendannamsbutler
committed
107174: testserver: avoid nodelocal capability in some cases r=knz a=stevendanna Waiting for the nodelocal capability takes time because we won't see the update until the closed timestamp for the relevant ranges advance. We could, and perhaps should, lower the closed timestamp target in tests. Or perhaps make other changes that avoid this long wait. But, while we decide on what to do, we can avoid doing this at all for tests that can't possibly be using nodelocal storage because they haven't set an external storage dir. Epic: CRDB-18499 Release note: None 107188: backup/kvserver: plumb backing file size through addSSTablePreApply() r=dt a=msbutler Epic: none Release note: none Co-authored-by: Steven Danna <[email protected]> Co-authored-by: Michael Butler <[email protected]>
3 parents 0c9f44f + 33b93eb + c723ac7 commit 0742137

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

pkg/ccl/backupccl/restore_job.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3202,7 +3202,11 @@ func sendAddRemoteSSTs(
32023202
}
32033203
}
32043204

3205-
loc := kvpb.AddSSTableRequest_RemoteFile{Locator: uris[i], Path: file.Path}
3205+
loc := kvpb.AddSSTableRequest_RemoteFile{
3206+
Locator: uris[i],
3207+
Path: file.Path,
3208+
BackingFileSize: file.BackingFileSize,
3209+
}
32063210
// TODO(dt): see if KV has any better ideas for making these up.
32073211
fileStats := &enginepb.MVCCStats{
32083212
ContainsEstimates: 1,

pkg/ccl/backupccl/restore_span_covering.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ func generateAndSendImportSpans(
476476
Path: f.Path,
477477
Dir: backups[layer].Dir,
478478
BackupFileEntrySpan: f.Span,
479-
BackupFileEntryCounts: f.EntryCounts}
479+
BackupFileEntryCounts: f.EntryCounts,
480+
BackingFileSize: f.BackingFileSize,
481+
}
480482
if dir, ok := backupLocalityMap[layer][f.LocalityKV]; ok {
481483
fileSpec.Dir = dir
482484
}

pkg/kv/kvpb/api.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,9 +2004,11 @@ message AddSSTableRequest {
20042004
//
20052005
// TODO(dt, msbutler, bilal): This is unsupported.
20062006
// TOOD(dt, msbutler, bilal): support sst_timestamp_to_request_timestamp.
2007+
// TODO(msbutler): rename to ExternalFile.
20072008
message RemoteFile {
20082009
string locator = 1;
20092010
string path = 2;
2011+
uint64 backing_file_size = 3;
20102012
}
20112013
RemoteFile remote_file = 10 [(gogoproto.nullable) = false];
20122014

pkg/kv/kvserver/batcheval/cmd_add_sstable.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ func EvalAddSSTable(
174174
return result.Result{
175175
Replicated: kvserverpb.ReplicatedEvalResult{
176176
AddSSTable: &kvserverpb.ReplicatedEvalResult_AddSSTable{
177-
RemoteFileLoc: args.RemoteFile.Locator,
178-
RemoteFilePath: args.RemoteFile.Path,
179-
Span: roachpb.Span{Key: start.Key, EndKey: end.Key},
177+
RemoteFileLoc: args.RemoteFile.Locator,
178+
RemoteFilePath: args.RemoteFile.Path,
179+
BackingFileSize: args.RemoteFile.BackingFileSize,
180+
Span: roachpb.Span{Key: start.Key, EndKey: end.Key},
180181
},
181182
MVCCHistoryMutation: mvccHistoryMutation,
182183
},

pkg/kv/kvserver/kvserverpb/proposer_kv.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ message ReplicatedEvalResult {
193193
// taken place since 22.1, to make sure all Raft log entries from 21.2 or
194194
// older have been applied on all replicas.
195195
bool at_write_timestamp = 4;
196-
196+
197+
// TODO(msbutler,dt): bikeshed the name of these fields.
197198
string remote_file_loc = 5;
198199
string remote_file_path = 6;
200+
uint64 backing_file_size = 7;
199201
}
200202
AddSSTable add_sstable = 17 [(gogoproto.customname) = "AddSSTable"];
201203

pkg/kv/kvserver/replica_proposal.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,9 @@ func addSSTablePreApply(
601601
) bool {
602602
if sst.RemoteFilePath != "" {
603603
// TODO(dt, bilal, msbutler): Replace this with eng.IngestRemoteFile()
604-
log.Warningf(ctx, "EXPERIMENTAL AddSSTABLE REMOTE FILE UNSUPPORTED; downloading %s from %s and adding it whole, ignoring span %s", sst.RemoteFilePath, sst.RemoteFileLoc, sst.Span)
604+
log.Warningf(ctx, "EXPERIMENTAL AddSSTABLE REMOTE FILE UNSUPPORTED; downloading %s ("+
605+
"with size %d) from %s and adding it whole, ignoring span %s", sst.RemoteFilePath,
606+
sst.BackingFileSize, sst.RemoteFileLoc, sst.Span)
605607
s, err := env.external.OpenURL(ctx, sst.RemoteFileLoc, username.SQLUsername{})
606608
if err != nil {
607609
log.Fatalf(ctx, "failed to open remote location %q below raft: %v", sst.RemoteFileLoc, err)

pkg/server/testserver.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,21 @@ func (ts *TestServer) StartTenant(
11461146
baseCfg.DisableTLSForHTTP = params.DisableTLSForHTTP
11471147
baseCfg.EnableDemoLoginEndpoint = params.EnableDemoLoginEndpoint
11481148

1149-
if ts.ClusterSettings().Version.IsActive(ctx, clusterversion.V23_1TenantCapabilities) {
1149+
// Waiting for capabilities can take 3+ seconds since the
1150+
// rangefeedcache needs to wait for the closed timestamp
1151+
// before flushing updates. To avoid paying this cost in all
1152+
// cases, we only set the nodelocal storage capability if the
1153+
// caller has configured an ExternalIODir since nodelocal
1154+
// storage only works with that configured.
1155+
//
1156+
// TODO(ssd): We should do more here. We could have the caller
1157+
// pass in explicitly that they want these capabilities. Or,
1158+
// we could modify the system in some way to avoid waiting on
1159+
// capabilities for so long. Also, note that this doesn't
1160+
// apply to StartSharedProcessTenant.
1161+
shouldGrantNodelocalCap := ts.params.ExternalIODir != ""
1162+
canGrantNodelocalCap := ts.ClusterSettings().Version.IsActive(ctx, clusterversion.V23_1TenantCapabilities)
1163+
if canGrantNodelocalCap && shouldGrantNodelocalCap {
11501164
_, err := ie.Exec(ctx, "testserver-alter-tenant-cap", nil,
11511165
"ALTER TENANT [$1] GRANT CAPABILITY can_use_nodelocal_storage", params.TenantID.ToUint64())
11521166
if err != nil {

pkg/sql/execinfrapb/processors_bulk_io.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ message RestoreFileSpec {
294294
reserved 4;
295295
optional roachpb.Span backup_file_entry_span = 5 [(gogoproto.nullable) = false];
296296
optional roachpb.RowCount backup_file_entry_counts = 6 [(gogoproto.nullable) = false];
297+
optional uint64 backing_file_size = 7 [(gogoproto.nullable) = false];
297298
}
298299

299300
message TableRekey {

0 commit comments

Comments
 (0)