-
Notifications
You must be signed in to change notification settings - Fork 455
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
[dbnode] Cache the results of the commitlog bootstapper between runs #2635
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,14 @@ type commitLogSource struct { | |
newReaderFn newReaderFn | ||
|
||
metrics commitLogSourceMetrics | ||
|
||
// Cache the results so the commit log is not read twice. This source is special since it reads the entire | ||
// time series range, irrespective of the requested time range. This is required since the commit log may hold | ||
// cold writes that have not been committed to a cold block. Another source might report it fulfilled a cold block, | ||
// but it could be missing writes only available in the commit log. | ||
// | ||
// The bootstrapper is single threaded so we don't need a mutex for this. | ||
bootstrapResults bootstrap.NamespaceResults | ||
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. What's the lifecycle of this? Any chance a downstream consumer will release the results in this map between te two reads? |
||
} | ||
|
||
type bootstrapNamespace struct { | ||
|
@@ -175,6 +183,12 @@ func (s *commitLogSource) Read( | |
ctx, span, _ := ctx.StartSampledTraceSpan(tracepoint.BootstrapperCommitLogSourceRead) | ||
defer span.Finish() | ||
|
||
// bail early if this source already ran before. | ||
if s.bootstrapResults.Results != nil { | ||
s.log.Info("the entire range of the commit has already been read. returning previous results") | ||
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. nit: maybe make this a debug log since this will get logged every time? |
||
return s.bootstrapResults, nil | ||
} | ||
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. Can we do this before the span is started? Currently we'll have a lot of 0 length spans if the cache is hit |
||
|
||
var ( | ||
// Emit bootstrapping gauge for duration of ReadData. | ||
doneReadingData = s.metrics.emitBootstrapping() | ||
|
@@ -521,9 +535,8 @@ func (s *commitLogSource) Read( | |
return bootstrap.NamespaceResults{}, err | ||
} | ||
|
||
bootstrapResult := bootstrap.NamespaceResults{ | ||
Results: bootstrap.NewNamespaceResultsMap(bootstrap.NamespaceResultsMapOptions{}), | ||
} | ||
s.bootstrapResults.Results = bootstrap.NewNamespaceResultsMap(bootstrap.NamespaceResultsMapOptions{}) | ||
|
||
for _, ns := range namespaceResults { | ||
id := ns.namespace.Metadata.ID() | ||
dataResult := result.NewDataBootstrapResult() | ||
|
@@ -539,15 +552,15 @@ func (s *commitLogSource) Read( | |
indexResult = shardTimeRanges.ToUnfulfilledIndexResult() | ||
} | ||
} | ||
bootstrapResult.Results.Set(id, bootstrap.NamespaceResult{ | ||
s.bootstrapResults.Results.Set(id, bootstrap.NamespaceResult{ | ||
Metadata: ns.namespace.Metadata, | ||
Shards: ns.namespace.Shards, | ||
DataResult: dataResult, | ||
IndexResult: indexResult, | ||
}) | ||
} | ||
|
||
return bootstrapResult, nil | ||
return s.bootstrapResults, nil | ||
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. I think we need to make sure these bootstrap results won't get loaded twice? |
||
} | ||
|
||
func (s *commitLogSource) snapshotFilesByShard( | ||
|
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.
nit:
the commitlog bootstrapper
vsthis source