Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batcheval: move remote sst handling to top #115078

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions pkg/kv/kvserver/batcheval/cmd_add_sstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,38 @@ func EvalAddSSTable(
defer span.Finish()
log.Eventf(ctx, "evaluating AddSSTable [%s,%s)", start.Key, end.Key)

// If this is a remote sst, just link it in and skip the rest of eval, since
// we do not do anything that touches the data inside an sst for remote ssts
// at the point of ingesting them.
if path := args.RemoteFile.Path; path != "" {
if len(args.Data) > 0 {
return result.Result{}, errors.AssertionFailedf("remote sst cannot include content")
}
log.VEventf(ctx, 1, "AddSSTable remote file %s in %s", path, args.RemoteFile.Locator)

// We have no idea if the SST being ingested contains keys that will shadow
// existing keys or not, so we need to force its mvcc stats to be estimates.
s := *args.MVCCStats
s.ContainsEstimates++
ms.Add(s)

return result.Result{
Replicated: kvserverpb.ReplicatedEvalResult{
AddSSTable: &kvserverpb.ReplicatedEvalResult_AddSSTable{
RemoteFileLoc: args.RemoteFile.Locator,
RemoteFilePath: path,
BackingFileSize: args.RemoteFile.BackingFileSize,
Span: roachpb.Span{Key: start.Key, EndKey: end.Key},
},
// Since the remote SST could contain keys at any timestamp, consider it
// a history mutation.
MVCCHistoryMutation: &kvserverpb.ReplicatedEvalResult_MVCCHistoryMutation{
Spans: []roachpb.Span{{Key: start.Key, EndKey: end.Key}},
},
},
}, nil
}

if min := addSSTableCapacityRemainingLimit.Get(&cArgs.EvalCtx.ClusterSettings().SV); min > 0 {
cap, err := cArgs.EvalCtx.GetEngineCapacity()
if err != nil {
Expand All @@ -160,33 +192,6 @@ func EvalAddSSTable(
}
}

if args.RemoteFile.Path != "" {
if len(args.Data) > 0 {
return result.Result{}, errors.AssertionFailedf(
"AddSSTable requests cannot add bytes and remote file at same time")
}
log.Infof(ctx, "AddSSTable of remote file: %s in %s", args.RemoteFile.Path, args.RemoteFile.Locator)
stats := *args.MVCCStats
stats.ContainsEstimates++

ms.Add(stats)

mvccHistoryMutation := &kvserverpb.ReplicatedEvalResult_MVCCHistoryMutation{
Spans: []roachpb.Span{{Key: start.Key, EndKey: end.Key}},
}
return result.Result{
Replicated: kvserverpb.ReplicatedEvalResult{
AddSSTable: &kvserverpb.ReplicatedEvalResult_AddSSTable{
RemoteFileLoc: args.RemoteFile.Locator,
RemoteFilePath: args.RemoteFile.Path,
BackingFileSize: args.RemoteFile.BackingFileSize,
Span: roachpb.Span{Key: start.Key, EndKey: end.Key},
},
MVCCHistoryMutation: mvccHistoryMutation,
},
}, nil
}

// Reject AddSSTable requests not writing at the request timestamp if requested.
if AddSSTableRequireAtRequestTimestamp.Get(&cArgs.EvalCtx.ClusterSettings().SV) &&
sstToReqTS.IsEmpty() {
Expand Down