diff --git a/src/dbnode/storage/block/block.go b/src/dbnode/storage/block/block.go index 9c96b9182d..1186fa3667 100644 --- a/src/dbnode/storage/block/block.go +++ b/src/dbnode/storage/block/block.go @@ -96,24 +96,6 @@ func NewDatabaseBlock( return b } -// NewRetrievableDatabaseBlock creates a new retrievable DatabaseBlock instance. -func NewRetrievableDatabaseBlock( - start time.Time, - blockSize time.Duration, - retriever DatabaseShardBlockRetriever, - metadata RetrievableBlockMetadata, - opts Options, -) DatabaseBlock { - b := &dbBlock{ - opts: opts, - startUnixNanos: start.UnixNano(), - blockSize: blockSize, - closed: false, - } - b.resetRetrievableWithLock(retriever, metadata) - return b -} - func (b *dbBlock) StartTime() time.Time { b.RLock() start := b.startWithRLock() @@ -185,26 +167,6 @@ func (b *dbBlock) Checksum() (uint32, error) { return b.checksum, nil } -func (b *dbBlock) OnRetrieveBlock( - id ident.ID, - _ ident.TagIterator, - startTime time.Time, - segment ts.Segment, -) { - b.Lock() - defer b.Unlock() - - if b.closed || - !id.Equal(b.retrieveID) || - !startTime.Equal(b.startWithRLock()) { - return - } - - b.resetSegmentWithLock(segment) - b.retrieveID = id - b.wasRetrievedFromDisk = true -} - func (b *dbBlock) Stream(blocker context.Context) (xio.BlockReader, error) { lockUpgraded := false @@ -296,18 +258,6 @@ func (b *dbBlock) Reset(start time.Time, blockSize time.Duration, segment ts.Seg b.resetSegmentWithLock(segment) } -func (b *dbBlock) ResetRetrievable( - start time.Time, - blockSize time.Duration, - retriever DatabaseShardBlockRetriever, - metadata RetrievableBlockMetadata, -) { - b.Lock() - defer b.Unlock() - b.resetNewBlockStartWithLock(start, blockSize) - b.resetRetrievableWithLock(retriever, metadata) -} - func (b *dbBlock) streamWithRLock(ctx context.Context) (xio.BlockReader, error) { start := b.startWithRLock() @@ -370,17 +320,6 @@ func (b *dbBlock) resetSegmentWithLock(seg ts.Segment) { b.wasRetrievedFromDisk = false } -func (b *dbBlock) resetRetrievableWithLock( - retriever DatabaseShardBlockRetriever, - metadata RetrievableBlockMetadata, -) { - b.segment = ts.Segment{} - b.length = metadata.Length - b.checksum = metadata.Checksum - b.retrieveID = metadata.ID - b.wasRetrievedFromDisk = false -} - func (b *dbBlock) Discard() ts.Segment { seg, _ := b.closeAndDiscardConditionally(nil) return seg diff --git a/src/dbnode/storage/block/block_mock.go b/src/dbnode/storage/block/block_mock.go index e2cf4e30ec..33d6b94b43 100644 --- a/src/dbnode/storage/block/block_mock.go +++ b/src/dbnode/storage/block/block_mock.go @@ -265,16 +265,6 @@ func (m *MockDatabaseBlock) EXPECT() *MockDatabaseBlockMockRecorder { return m.recorder } -// OnRetrieveBlock mocks base method -func (m *MockDatabaseBlock) OnRetrieveBlock(id ident.ID, tags ident.TagIterator, startTime time.Time, segment ts.Segment) { - m.ctrl.Call(m, "OnRetrieveBlock", id, tags, startTime, segment) -} - -// OnRetrieveBlock indicates an expected call of OnRetrieveBlock -func (mr *MockDatabaseBlockMockRecorder) OnRetrieveBlock(id, tags, startTime, segment interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnRetrieveBlock", reflect.TypeOf((*MockDatabaseBlock)(nil).OnRetrieveBlock), id, tags, startTime, segment) -} - // StartTime mocks base method func (m *MockDatabaseBlock) StartTime() time.Time { ret := m.ctrl.Call(m, "StartTime") diff --git a/src/dbnode/storage/block/types.go b/src/dbnode/storage/block/types.go index adc10b0a4a..4ee8c24add 100644 --- a/src/dbnode/storage/block/types.go +++ b/src/dbnode/storage/block/types.go @@ -135,8 +135,6 @@ type NewDatabaseBlockFn func() DatabaseBlock // DatabaseBlock is the interface for a DatabaseBlock type DatabaseBlock interface { - OnRetrieveBlock - // StartTime returns the start time of the block. StartTime() time.Time @@ -174,14 +172,6 @@ type DatabaseBlock interface { // Reset resets the block start time, duration, and the segment. Reset(startTime time.Time, blockSize time.Duration, segment ts.Segment) - // ResetRetrievable resets the block to become retrievable. - ResetRetrievable( - startTime time.Time, - blockSize time.Duration, - retriever DatabaseShardBlockRetriever, - metadata RetrievableBlockMetadata, - ) - // Discard closes the block, but returns the (unfinalized) segment. Discard() ts.Segment diff --git a/src/dbnode/storage/series/series.go b/src/dbnode/storage/series/series.go index d95b0c4571..46bb5a5820 100644 --- a/src/dbnode/storage/series/series.go +++ b/src/dbnode/storage/series/series.go @@ -520,21 +520,8 @@ func (s *dbSeries) OnRetrieveBlock( } b = s.opts.DatabaseBlockOptions().DatabaseBlockPool().Get() - metadata := block.RetrievableBlockMetadata{ - ID: s.id, - Length: segment.Len(), - Checksum: digest.SegmentChecksum(segment), - } blockSize := s.opts.RetentionOptions().BlockSize() - b.ResetRetrievable(startTime, blockSize, s.blockRetriever, metadata) - // Use s.id instead of id here, because id is finalized by the context whereas - // we rely on the G.C to reclaim s.id. This is important because the block will - // hold onto the id ref, and (if the LRU caching policy is enabled) the shard - // will need it later when the WiredList calls its OnEvictedFromWiredList method. - // Also note that ResetRetrievable will mark the block as not retrieved from disk, - // but OnRetrieveBlock will then properly mark it as retrieved from disk so subsequent - // calls to WasRetrievedFromDisk will return true. - b.OnRetrieveBlock(s.id, tags, startTime, segment) + b.Reset(startTime, blockSize, segment) // NB(r): Blocks retrieved have been triggered by a read, so set the last // read time as now so caching policies are followed.