diff --git a/src/dbnode/storage/block/block.go b/src/dbnode/storage/block/block.go index a3a6133f61..5d77905699 100644 --- a/src/dbnode/storage/block/block.go +++ b/src/dbnode/storage/block/block.go @@ -73,9 +73,9 @@ type dbBlock struct { } type listState struct { - next DatabaseBlock - prev DatabaseBlock - nextPrevUpdatedAtUnixNano int64 + next DatabaseBlock + prev DatabaseBlock + enteredListAtUnixNano int64 } // NewDatabaseBlock creates a new DatabaseBlock instance. @@ -488,13 +488,13 @@ func (b *dbBlock) setPrev(value DatabaseBlock) { } // Should only be used by the WiredList. -func (b *dbBlock) nextPrevUpdatedAtUnixNano() int64 { - return b.listState.nextPrevUpdatedAtUnixNano +func (b *dbBlock) enteredListAtUnixNano() int64 { + return b.listState.enteredListAtUnixNano } // Should only be used by the WiredList. -func (b *dbBlock) setNextPrevUpdatedAtUnixNano(value int64) { - b.listState.nextPrevUpdatedAtUnixNano = value +func (b *dbBlock) setEnteredListAtUnixNano(value int64) { + b.listState.enteredListAtUnixNano = value } // wiredListEntry is a snapshot of a subset of the block's state that the WiredList diff --git a/src/dbnode/storage/block/block_mock.go b/src/dbnode/storage/block/block_mock.go index 9418eda897..e6e757a660 100644 --- a/src/dbnode/storage/block/block_mock.go +++ b/src/dbnode/storage/block/block_mock.go @@ -539,26 +539,26 @@ func (mr *MockDatabaseBlockMockRecorder) setPrev(block interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setPrev", reflect.TypeOf((*MockDatabaseBlock)(nil).setPrev), block) } -// nextPrevUpdatedAtUnixNano mocks base method -func (m *MockDatabaseBlock) nextPrevUpdatedAtUnixNano() int64 { - ret := m.ctrl.Call(m, "nextPrevUpdatedAtUnixNano") +// enteredListAtUnixNano mocks base method +func (m *MockDatabaseBlock) enteredListAtUnixNano() int64 { + ret := m.ctrl.Call(m, "enteredListAtUnixNano") ret0, _ := ret[0].(int64) return ret0 } -// nextPrevUpdatedAtUnixNano indicates an expected call of nextPrevUpdatedAtUnixNano -func (mr *MockDatabaseBlockMockRecorder) nextPrevUpdatedAtUnixNano() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "nextPrevUpdatedAtUnixNano", reflect.TypeOf((*MockDatabaseBlock)(nil).nextPrevUpdatedAtUnixNano)) +// enteredListAtUnixNano indicates an expected call of enteredListAtUnixNano +func (mr *MockDatabaseBlockMockRecorder) enteredListAtUnixNano() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "enteredListAtUnixNano", reflect.TypeOf((*MockDatabaseBlock)(nil).enteredListAtUnixNano)) } -// setNextPrevUpdatedAtUnixNano mocks base method -func (m *MockDatabaseBlock) setNextPrevUpdatedAtUnixNano(value int64) { - m.ctrl.Call(m, "setNextPrevUpdatedAtUnixNano", value) +// setEnteredListAtUnixNano mocks base method +func (m *MockDatabaseBlock) setEnteredListAtUnixNano(value int64) { + m.ctrl.Call(m, "setEnteredListAtUnixNano", value) } -// setNextPrevUpdatedAtUnixNano indicates an expected call of setNextPrevUpdatedAtUnixNano -func (mr *MockDatabaseBlockMockRecorder) setNextPrevUpdatedAtUnixNano(value interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setNextPrevUpdatedAtUnixNano", reflect.TypeOf((*MockDatabaseBlock)(nil).setNextPrevUpdatedAtUnixNano), value) +// setEnteredListAtUnixNano indicates an expected call of setEnteredListAtUnixNano +func (mr *MockDatabaseBlockMockRecorder) setEnteredListAtUnixNano(value interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setEnteredListAtUnixNano", reflect.TypeOf((*MockDatabaseBlock)(nil).setEnteredListAtUnixNano), value) } // wiredListEntry mocks base method @@ -640,26 +640,26 @@ func (mr *MockdatabaseBlockMockRecorder) setPrev(block interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setPrev", reflect.TypeOf((*MockdatabaseBlock)(nil).setPrev), block) } -// nextPrevUpdatedAtUnixNano mocks base method -func (m *MockdatabaseBlock) nextPrevUpdatedAtUnixNano() int64 { - ret := m.ctrl.Call(m, "nextPrevUpdatedAtUnixNano") +// enteredListAtUnixNano mocks base method +func (m *MockdatabaseBlock) enteredListAtUnixNano() int64 { + ret := m.ctrl.Call(m, "enteredListAtUnixNano") ret0, _ := ret[0].(int64) return ret0 } -// nextPrevUpdatedAtUnixNano indicates an expected call of nextPrevUpdatedAtUnixNano -func (mr *MockdatabaseBlockMockRecorder) nextPrevUpdatedAtUnixNano() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "nextPrevUpdatedAtUnixNano", reflect.TypeOf((*MockdatabaseBlock)(nil).nextPrevUpdatedAtUnixNano)) +// enteredListAtUnixNano indicates an expected call of enteredListAtUnixNano +func (mr *MockdatabaseBlockMockRecorder) enteredListAtUnixNano() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "enteredListAtUnixNano", reflect.TypeOf((*MockdatabaseBlock)(nil).enteredListAtUnixNano)) } -// setNextPrevUpdatedAtUnixNano mocks base method -func (m *MockdatabaseBlock) setNextPrevUpdatedAtUnixNano(value int64) { - m.ctrl.Call(m, "setNextPrevUpdatedAtUnixNano", value) +// setEnteredListAtUnixNano mocks base method +func (m *MockdatabaseBlock) setEnteredListAtUnixNano(value int64) { + m.ctrl.Call(m, "setEnteredListAtUnixNano", value) } -// setNextPrevUpdatedAtUnixNano indicates an expected call of setNextPrevUpdatedAtUnixNano -func (mr *MockdatabaseBlockMockRecorder) setNextPrevUpdatedAtUnixNano(value interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setNextPrevUpdatedAtUnixNano", reflect.TypeOf((*MockdatabaseBlock)(nil).setNextPrevUpdatedAtUnixNano), value) +// setEnteredListAtUnixNano indicates an expected call of setEnteredListAtUnixNano +func (mr *MockdatabaseBlockMockRecorder) setEnteredListAtUnixNano(value interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setEnteredListAtUnixNano", reflect.TypeOf((*MockdatabaseBlock)(nil).setEnteredListAtUnixNano), value) } // wiredListEntry mocks base method diff --git a/src/dbnode/storage/block/types.go b/src/dbnode/storage/block/types.go index 54cb6f2bdb..97fa6eea7d 100644 --- a/src/dbnode/storage/block/types.go +++ b/src/dbnode/storage/block/types.go @@ -218,8 +218,8 @@ type databaseBlock interface { setNext(block DatabaseBlock) prev() DatabaseBlock setPrev(block DatabaseBlock) - nextPrevUpdatedAtUnixNano() int64 - setNextPrevUpdatedAtUnixNano(value int64) + enteredListAtUnixNano() int64 + setEnteredListAtUnixNano(value int64) wiredListEntry() wiredListEntry } diff --git a/src/dbnode/storage/block/wired_list.go b/src/dbnode/storage/block/wired_list.go index aa60008884..0218e177cd 100644 --- a/src/dbnode/storage/block/wired_list.go +++ b/src/dbnode/storage/block/wired_list.go @@ -242,7 +242,6 @@ func (l *WiredList) insertAfter(v, at DatabaseBlock) { at.setNext(v) v.setPrev(at) v.setNext(n) - v.setNextPrevUpdatedAtUnixNano(now.UnixNano()) n.setPrev(v) l.length++ @@ -292,8 +291,8 @@ func (l *WiredList) insertAfter(v, at DatabaseBlock) { l.metrics.evicted.Inc(1) - lastUpdatedAt := time.Unix(0, bl.nextPrevUpdatedAtUnixNano()) - l.metrics.evictedAfterDuration.Record(now.Sub(lastUpdatedAt)) + enteredListAt := time.Unix(0, bl.enteredListAtUnixNano()) + l.metrics.evictedAfterDuration.Record(now.Sub(enteredListAt)) bl = nextBl } @@ -320,6 +319,7 @@ func (l *WiredList) pushBack(v DatabaseBlock) { l.metrics.inserted.Inc(1) l.insertAfter(v, l.root.prev()) + v.setEnteredListAtUnixNano(l.nowFn().UnixNano()) } func (l *WiredList) moveToBack(v DatabaseBlock) {