-
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
Add support for incrementally persisting the active block in the peers bootstrapper as a snapshot #903
Merged
Merged
Add support for incrementally persisting the active block in the peers bootstrapper as a snapshot #903
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
44bf00b
Refactor commit log bootstrapper to only return it can satisfy everyt…
6060492
Fix lint issues
77f94c8
Working imlementation
1220e9e
fix lint issues
554bdfc
Fix copyright year
e6ef6fe
Simplify integration test
f1370e7
Change name of var
b0ef427
Remove panic and rename incrementalconfig to persistconfig
3636222
Regen mocks and fix naming
4579370
Rename
760640b
More renaming
228a26e
Add explanatory comment
1281f76
More comments
f65a4e4
Add test for invalid fileset type in persistconfig
7352861
Make fs bootstrapper ignore snapshot persists
a227067
Add test to make sure fs skips snapshot persist
1b4b269
Remove panic
cedc702
Remove commented out code and add comments
0b378cd
Rename all the things
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
35 changes: 35 additions & 0 deletions
35
src/dbnode/integration/cluster_add_one_node_commitlog_test.go
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build integration | ||
|
||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package integration | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestClusterAddOneNodeCommitlog(t *testing.T) { | ||
if testing.Short() { | ||
t.SkipNow() | ||
} | ||
|
||
testClusterAddOneNode(t, true) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,15 +220,15 @@ func (s *fileSystemSource) enqueueReaders( | |
// Close the readers ch if and only if all readers are enqueued | ||
defer close(readersCh) | ||
|
||
indexIncrementalBootstrap := run == bootstrapIndexRunType && runOpts.Incremental() | ||
if !indexIncrementalBootstrap { | ||
shouldPersistIndexBootstrap := run == bootstrapIndexRunType && s.shouldPersist(runOpts) | ||
if !shouldPersistIndexBootstrap { | ||
// Normal run, open readers | ||
s.enqueueReadersGroupedByBlockSize(ns, run, runOpts, | ||
shardsTimeRanges, readerPool, readersCh) | ||
return | ||
} | ||
|
||
// If the run is an index bootstrap using incremental bootstrapping | ||
// If the run is an index bootstrap with the persist configuration enabled | ||
// then we need to write out the metadata into FSTs that we store on disk, | ||
// to avoid creating any one single huge FST at once we bucket the | ||
// shards into number of buckets | ||
|
@@ -594,18 +594,20 @@ func (s *fileSystemSource) loadShardReadersDataIntoShardResult( | |
} | ||
} | ||
|
||
incremental := runOpts.Incremental() | ||
noneRemaining := remainingRanges.IsEmpty() | ||
if run == bootstrapIndexRunType && incremental && noneRemaining { | ||
err := s.incrementalBootstrapIndexSegment(ns, requestedRanges, runResult) | ||
var ( | ||
shouldPersist = s.shouldPersist(runOpts) | ||
noneRemaining = remainingRanges.IsEmpty() | ||
) | ||
if run == bootstrapIndexRunType && shouldPersist && noneRemaining { | ||
err := s.persistBootstrapIndexSegment(ns, requestedRanges, runResult) | ||
if err != nil { | ||
iopts := s.opts.ResultOptions().InstrumentOptions() | ||
log := instrument.EmitInvariantViolationAndGetLogger(iopts) | ||
log.WithFields( | ||
xlog.NewField("namespace", ns.ID().String()), | ||
xlog.NewField("requestedRanges", requestedRanges.String()), | ||
xlog.NewField("error", err.Error()), | ||
).Error("incremental fs index bootstrap failed") | ||
).Error("persist fs index bootstrap failed") | ||
} | ||
} | ||
|
||
|
@@ -755,12 +757,12 @@ func (s *fileSystemSource) readNextEntryAndIndex( | |
return err | ||
} | ||
|
||
func (s *fileSystemSource) incrementalBootstrapIndexSegment( | ||
func (s *fileSystemSource) persistBootstrapIndexSegment( | ||
ns namespace.Metadata, | ||
requestedRanges result.ShardTimeRanges, | ||
runResult *runResult, | ||
) error { | ||
// If we're performing an index run in incremental mode | ||
// If we're performing an index run with persistence enabled | ||
// determine if we covered a full block exactly (which should | ||
// occur since we always group readers by block size) | ||
min, max := requestedRanges.MinMax() | ||
|
@@ -839,7 +841,7 @@ func (s *fileSystemSource) incrementalBootstrapIndexSegment( | |
requireFulfilled.Subtract(fulfilled) | ||
exactStartEnd := min.Equal(blockStart) && max.Equal(blockStart.Add(blockSize)) | ||
if !exactStartEnd || !requireFulfilled.IsEmpty() { | ||
return fmt.Errorf("incremental fs index bootstrap invalid ranges to persist: expected=%v, actual=%v, fulfilled=%v", | ||
return fmt.Errorf("persistent fs index bootstrap invalid ranges to persist: expected=%v, actual=%v, fulfilled=%v", | ||
expectedRanges.String(), requestedRanges.String(), fulfilled.String()) | ||
} | ||
|
||
|
@@ -1155,6 +1157,11 @@ func (s *fileSystemSource) bootstrapFromIndexPersistedBlocks( | |
return res, nil | ||
} | ||
|
||
func (s *fileSystemSource) shouldPersist(runOpts bootstrap.RunOptions) bool { | ||
persistConfig := runOpts.PersistConfig() | ||
return persistConfig.Enabled && persistConfig.FileSetType == persist.FileSetFlushType | ||
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. +1 |
||
} | ||
|
||
type timeWindowReaders struct { | ||
ranges result.ShardTimeRanges | ||
readers map[shardID]shardReaders | ||
|
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
Oops, something went wrong.
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.
do you need to reset the bootstrappers here - i.e. ensure it doesn't use peers again?
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.
nah startServerWithNewInspection completely reconstructs the bootstrappers