-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
backupccl,kvserver: log failed ExportRequest trace on client and server #102793
Merged
craig
merged 1 commit into
cockroachdb:master
from
adityamaru:print-export-request-trace
May 15, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import ( | |
"github.com/cockroachdb/cockroach/pkg/sql/rowenc" | ||
"github.com/cockroachdb/cockroach/pkg/sql/rowexec" | ||
"github.com/cockroachdb/cockroach/pkg/sql/types" | ||
"github.com/cockroachdb/cockroach/pkg/util" | ||
"github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb" | ||
"github.com/cockroachdb/cockroach/pkg/util/bulk" | ||
"github.com/cockroachdb/cockroach/pkg/util/contextutil" | ||
|
@@ -40,6 +41,7 @@ import ( | |
"github.com/cockroachdb/cockroach/pkg/util/stop" | ||
"github.com/cockroachdb/cockroach/pkg/util/timeutil" | ||
"github.com/cockroachdb/cockroach/pkg/util/tracing" | ||
"github.com/cockroachdb/cockroach/pkg/util/tracing/tracingpb" | ||
"github.com/cockroachdb/errors" | ||
"github.com/cockroachdb/logtags" | ||
"github.com/cockroachdb/redact" | ||
|
@@ -55,7 +57,7 @@ var ( | |
time.Minute, | ||
settings.NonNegativeDuration, | ||
).WithPublic() | ||
delayPerAttmpt = settings.RegisterDurationSetting( | ||
delayPerAttempt = settings.RegisterDurationSetting( | ||
settings.TenantWritable, | ||
"bulkio.backup.read_retry_delay", | ||
"amount of time since the read-as-of time, per-prior attempt, to wait before making another attempt", | ||
|
@@ -82,6 +84,13 @@ var ( | |
"split backup data on timestamps when writing revision history", | ||
true, | ||
) | ||
|
||
sendExportRequestWithVerboseTracing = settings.RegisterBoolSetting( | ||
settings.TenantWritable, | ||
"bulkio.backup.export_request_verbose_tracing", | ||
"send each export request with a verbose tracing span", | ||
util.ConstantWithMetamorphicTestBool("export_request_verbose_tracing", false), | ||
) | ||
) | ||
|
||
const ( | ||
|
@@ -378,7 +387,7 @@ func runBackupProcessor( | |
// We're okay with delaying this worker until then since we assume any | ||
// other work it could pull off the queue will likely want to delay to | ||
// a similar or later time anyway. | ||
if delay := delayPerAttmpt.Get(&clusterSettings.SV) - timeutil.Since(span.lastTried); delay > 0 { | ||
if delay := delayPerAttempt.Get(&clusterSettings.SV) - timeutil.Since(span.lastTried); delay > 0 { | ||
timer.Reset(delay) | ||
log.Infof(ctx, "waiting %s to start attempt %d of remaining spans", delay, span.attempts+1) | ||
select { | ||
|
@@ -427,13 +436,22 @@ func runBackupProcessor( | |
log.VEventf(ctx, 1, "sending ExportRequest for span %s (attempt %d, priority %s)", | ||
span.span, span.attempts+1, header.UserPriority.String()) | ||
var rawResp kvpb.Response | ||
var recording tracingpb.Recording | ||
var pErr *kvpb.Error | ||
requestSentAt := timeutil.Now() | ||
exportRequestErr := contextutil.RunWithTimeout(ctx, | ||
fmt.Sprintf("ExportRequest for span %s", span.span), | ||
timeoutPerAttempt.Get(&clusterSettings.SV), func(ctx context.Context) error { | ||
sp := tracing.SpanFromContext(ctx) | ||
opts := make([]tracing.SpanOption, 0) | ||
opts = append(opts, tracing.WithParent(sp)) | ||
if sendExportRequestWithVerboseTracing.Get(&clusterSettings.SV) { | ||
opts = append(opts, tracing.WithRecording(tracingpb.RecordingVerbose)) | ||
} | ||
ctx, exportSpan := sp.Tracer().StartSpanCtx(ctx, "backupccl.ExportRequest", opts...) | ||
rawResp, pErr = kv.SendWrappedWithAdmission( | ||
ctx, flowCtx.Cfg.DB.KV().NonTransactionalSender(), header, admissionHeader, req) | ||
recording = exportSpan.FinishAndGetConfiguredRecording() | ||
if pErr != nil { | ||
return pErr.GoError() | ||
} | ||
|
@@ -453,6 +471,9 @@ func runBackupProcessor( | |
// TimeoutError improves the opaque `context deadline exceeded` error | ||
// message so use that instead. | ||
if errors.HasType(exportRequestErr, (*contextutil.TimeoutError)(nil)) { | ||
if recording != nil { | ||
log.Errorf(ctx, "failed export request for span %s\n trace:\n%s", span.span, recording) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here and below: unnecessary space before |
||
} | ||
return errors.Wrap(exportRequestErr, "export request timeout") | ||
} | ||
// BatchTimestampBeforeGCError is returned if the ExportRequest | ||
|
@@ -467,6 +488,10 @@ func runBackupProcessor( | |
continue | ||
} | ||
} | ||
|
||
if recording != nil { | ||
log.Errorf(ctx, "failed export request %s\n trace:\n%s", span.span, recording) | ||
} | ||
return errors.Wrapf(exportRequestErr, "exporting %s", span.span) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this name was validated by the test
TestLintClusterSettingNames
inpkg/sql/show_test.go
? It's not valid per that linter. Ditto the_delay
one above.