Skip to content

Commit

Permalink
For bootstrapping just use presence of datafiles
Browse files Browse the repository at this point in the history
  • Loading branch information
rallen090 committed Aug 19, 2021
1 parent c68120b commit 6651096
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 51 deletions.
12 changes: 0 additions & 12 deletions src/dbnode/storage/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,18 +1112,6 @@ func (i *nsIndex) ColdFlush(shards []databaseShard) (OnColdFlushDone, error) {
}, nil
}

// WarmFlushedBlockStarts returns all index blockStarts which have been flushed to disk.
func (i *nsIndex) WarmFlushedBlockStarts() []xtime.UnixNano {
flushed := make([]xtime.UnixNano, 0)
infoFiles := i.readInfoFilesAsMap()
for blockStart := range infoFiles {
if i.hasIndexWarmFlushedToDisk(infoFiles, blockStart) {
flushed = append(flushed, blockStart)
}
}
return flushed
}

func (i *nsIndex) readInfoFilesAsMap() map[xtime.UnixNano]fs.ReadIndexInfoFileResult {
fsOpts := i.opts.CommitLogOptions().FilesystemOptions()
infoFiles := i.readIndexInfoFilesFn(fs.ReadIndexInfoFilesOptions{
Expand Down
32 changes: 10 additions & 22 deletions src/dbnode/storage/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -1964,11 +1964,19 @@ func (s *dbShard) UpdateFlushStates() {
info := result.Info
at := xtime.UnixNano(info.BlockStart)
currState := s.flushStateNoBootstrapCheck(at)

// When initializing from disk, the data files being present are sufficient
// for considering the data+index are flushed because that distinction is only
// needed to account for the raciness surrounding GCing series based on when
// data + index flushes have occurred. For the purposes of just initializing
// the state of which blocks have been flushed when bootstrapping, we can
// just use the data being present as the indicator.
if currState.WarmStatus.DataFlushed != fileOpSuccess {
s.markWarmDataFlushStateSuccess(at)
}

// we need to init if index is flushed to pull into this granular state.
if currState.WarmStatus.IndexFlushed != fileOpSuccess {
s.markWarmIndexFlushStateSuccess(at)
}

// Cold version needs to get bootstrapped so that the 1:1 relationship
// between volume number and cold version is maintained and the volume
Expand All @@ -1982,26 +1990,6 @@ func (s *dbShard) UpdateFlushStates() {
s.setFlushStateColdVersionFlushed(at, info.VolumeIndex)
}
}

// Populate index flush state only if enabled.
if !s.namespace.Options().IndexOptions().Enabled() {
return
}

blockSize := s.namespace.Options().RetentionOptions().BlockSize()
indexBlockSize := s.namespace.Options().IndexOptions().BlockSize()

indexFlushedBlockStarts := s.reverseIndex.WarmFlushedBlockStarts()
for _, blockStart := range indexFlushedBlockStarts {
// Index block size is wider than data block size, so we want to set all data blockStarts
// within the range of a given index blockStart
for at := blockStart; at < blockStart.Add(indexBlockSize); at = at.Add(blockSize) {
currState := s.flushStateNoBootstrapCheck(at)
if currState.WarmStatus.IndexFlushed != fileOpSuccess {
s.markWarmIndexFlushStateSuccess(at)
}
}
}
}

func (s *dbShard) Bootstrap(
Expand Down
14 changes: 0 additions & 14 deletions src/dbnode/storage/storage_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/dbnode/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,6 @@ type NamespaceIndex interface {
shards []databaseShard,
) error

// WarmFlushedBlockStarts returns all index blockStarts which have been flushed to disk.
WarmFlushedBlockStarts() []xtime.UnixNano

// ColdFlush performs any cold flushes that the index has outstanding using
// the owned shards of the database. Also returns a callback to be called when
// cold flushing completes to perform houskeeping.
Expand Down

0 comments on commit 6651096

Please sign in to comment.