Skip to content

Commit

Permalink
[dbnode] Remove reverse index sharing leftovers (#3095)
Browse files Browse the repository at this point in the history
  • Loading branch information
linasm authored Jan 18, 2021
1 parent 5b4f793 commit acbe533
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 326 deletions.
37 changes: 7 additions & 30 deletions src/dbnode/storage/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ var (
type nsIndex struct {
state nsIndexState

extendedRetentionPeriod time.Duration

// all the vars below this line are not modified past the ctor
// and don't require a lock when being accessed.
nowFn clock.NowFn
Expand Down Expand Up @@ -658,7 +656,7 @@ func (i *nsIndex) writeBatches(
blockSize = i.blockSize
futureLimit = now.Add(1 * i.bufferFuture)
pastLimit = now.Add(-1 * i.bufferPast)
earliestBlockStartToRetain = i.earliestBlockStartToRetainWithLock(now)
earliestBlockStartToRetain = retention.FlushTimeStartForRetentionPeriod(i.retentionPeriod, i.blockSize, now)
batchOptions = batch.Options()
forwardIndexDice = i.forwardIndexDice
forwardIndexEnabled = forwardIndexDice.enabled
Expand Down Expand Up @@ -866,16 +864,17 @@ func (i *nsIndex) Bootstrapped() bool {
}

func (i *nsIndex) Tick(c context.Cancellable, startTime time.Time) (namespaceIndexTickResult, error) {
var result namespaceIndexTickResult
var (
result = namespaceIndexTickResult{}
earliestBlockStartToRetain = retention.FlushTimeStartForRetentionPeriod(i.retentionPeriod, i.blockSize, startTime)
)

i.state.Lock()
defer func() {
i.updateBlockStartsWithLock()
i.state.Unlock()
}()

earliestBlockStartToRetain := i.earliestBlockStartToRetainWithLock(startTime)

result.NumBlocks = int64(len(i.state.blocksByTime))

var multiErr xerrors.MultiError
Expand Down Expand Up @@ -1033,7 +1032,7 @@ func (i *nsIndex) flushableBlocks(
flushable := make([]index.Block, 0, len(i.state.blocksByTime))

now := i.nowFn()
earliestBlockStartToRetain := i.earliestBlockStartToRetainWithLock(now)
earliestBlockStartToRetain := retention.FlushTimeStartForRetentionPeriod(i.retentionPeriod, i.blockSize, now)
currentBlockStart := now.Truncate(i.blockSize)
// Check for flushable blocks by iterating through all block starts w/in retention.
for blockStart := earliestBlockStartToRetain; blockStart.Before(currentBlockStart); blockStart = blockStart.Add(i.blockSize) {
Expand Down Expand Up @@ -1973,7 +1972,7 @@ func (i *nsIndex) CleanupExpiredFileSets(t time.Time) error {
}

// earliest block to retain based on retention period
earliestBlockStartToRetain := i.earliestBlockStartToRetainWithLock(t)
earliestBlockStartToRetain := retention.FlushTimeStartForRetentionPeriod(i.retentionPeriod, i.blockSize, t)

// now we loop through the blocks we hold, to ensure we don't delete any data for them.
for t := range i.state.blocksByTime {
Expand Down Expand Up @@ -2182,28 +2181,6 @@ func (i *nsIndex) unableToAllocBlockInvariantError(err error) error {
return ierr
}

func (i *nsIndex) SetExtendedRetentionPeriod(period time.Duration) {
i.state.Lock()
defer i.state.Unlock()

if period > i.extendedRetentionPeriod {
i.extendedRetentionPeriod = period
}
}

func (i *nsIndex) effectiveRetentionPeriodWithLock() time.Duration {
period := i.retentionPeriod
if i.extendedRetentionPeriod > period {
period = i.extendedRetentionPeriod
}

return period
}

func (i *nsIndex) earliestBlockStartToRetainWithLock(t time.Time) time.Time {
return retention.FlushTimeStartForRetentionPeriod(i.effectiveRetentionPeriodWithLock(), i.blockSize, t)
}

type nsIndexMetrics struct {
asyncInsertAttemptTotal tally.Counter
asyncInsertAttemptSkip tally.Counter
Expand Down
18 changes: 0 additions & 18 deletions src/dbnode/storage/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,24 +378,6 @@ func TestNamespaceIndexQueryNoMatchingBlocks(t *testing.T) {
require.NoError(t, err)
}

func TestNamespaceIndexSetExtendedRetentionPeriod(t *testing.T) {
ctrl := gomock.NewController(xtest.Reporter{T: t})
defer ctrl.Finish()

idx := newTestIndex(t, ctrl).index.(*nsIndex)
originalRetention := idx.retentionPeriod

assert.Equal(t, originalRetention, idx.effectiveRetentionPeriodWithLock())

longerRetention := originalRetention + time.Minute
idx.SetExtendedRetentionPeriod(longerRetention)
assert.Equal(t, longerRetention, idx.effectiveRetentionPeriodWithLock())

shorterRetention := longerRetention - time.Second
idx.SetExtendedRetentionPeriod(shorterRetention)
assert.Equal(t, longerRetention, idx.effectiveRetentionPeriodWithLock())
}

func verifyFlushForShards(
t *testing.T,
ctrl *gomock.Controller,
Expand Down
134 changes: 0 additions & 134 deletions src/dbnode/storage/readonly_index_proxy.go

This file was deleted.

128 changes: 0 additions & 128 deletions src/dbnode/storage/readonly_index_proxy_test.go

This file was deleted.

Loading

0 comments on commit acbe533

Please sign in to comment.