From 4fe5430d6b11acc8dda934eb658e8dd1e52b8198 Mon Sep 17 00:00:00 2001 From: Linas Naginionis Date: Tue, 30 Mar 2021 11:51:02 +0300 Subject: [PATCH] use `IsBootstrappedAndDurable()` instead of `IsBootstrapped()` otherwise warm and cold flushes might fail because some shards might still be not bootstrapped. --- src/dbnode/storage/coldflush.go | 4 ++-- src/dbnode/storage/coldflush_test.go | 2 +- src/dbnode/storage/fs.go | 4 ++-- src/dbnode/storage/fs_test.go | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dbnode/storage/coldflush.go b/src/dbnode/storage/coldflush.go index 9229b5de8b..319ab41693 100644 --- a/src/dbnode/storage/coldflush.go +++ b/src/dbnode/storage/coldflush.go @@ -106,7 +106,7 @@ func (m *coldFlushManager) Run(t time.Time) bool { // and not caught in CI or integration tests. // When an invariant occurs in CI tests it panics so as to fail // the build. - if err := m.ColdFlushCleanup(t, m.database.IsBootstrapped()); err != nil { + if err := m.ColdFlushCleanup(t, m.database.IsBootstrappedAndDurable()); err != nil { instrument.EmitAndLogInvariantViolation(m.opts.InstrumentOptions(), func(l *zap.Logger) { l.Error("error when cleaning up cold flush data", zap.Time("time", t), zap.Error(err)) @@ -195,7 +195,7 @@ func (m *coldFlushManager) Report() { } func (m *coldFlushManager) shouldRunWithLock() bool { - return m.enabled && m.status != fileOpInProgress && m.database.IsBootstrapped() + return m.enabled && m.status != fileOpInProgress && m.database.IsBootstrappedAndDurable() } type coldFlushNsOpts struct { diff --git a/src/dbnode/storage/coldflush_test.go b/src/dbnode/storage/coldflush_test.go index 55eb3d355c..a6863b9750 100644 --- a/src/dbnode/storage/coldflush_test.go +++ b/src/dbnode/storage/coldflush_test.go @@ -57,7 +57,7 @@ func TestColdFlushManagerFlushAlreadyInProgress(t *testing.T) { testOpts := DefaultTestOptions().SetPersistManager(mockPersistManager) db := newMockdatabase(ctrl) db.EXPECT().Options().Return(testOpts).AnyTimes() - db.EXPECT().IsBootstrapped().Return(true).AnyTimes() + db.EXPECT().IsBootstrappedAndDurable().Return(true).AnyTimes() db.EXPECT().OwnedNamespaces().Return(nil, nil).AnyTimes() cfm := newColdFlushManager(db, mockPersistManager, testOpts).(*coldFlushManager) diff --git a/src/dbnode/storage/fs.go b/src/dbnode/storage/fs.go index e6363f75f0..3286cfe68b 100644 --- a/src/dbnode/storage/fs.go +++ b/src/dbnode/storage/fs.go @@ -158,7 +158,7 @@ func (m *fileSystemManager) Run( // and not caught in CI or integration tests. // When an invariant occurs in CI tests it panics so as to fail // the build. - if err := m.WarmFlushCleanup(t, m.database.IsBootstrapped()); err != nil { + if err := m.WarmFlushCleanup(t, m.database.IsBootstrappedAndDurable()); err != nil { instrument.EmitAndLogInvariantViolation(m.opts.InstrumentOptions(), func(l *zap.Logger) { l.Error("error when cleaning up data", zap.Time("time", t), zap.Error(err)) @@ -189,5 +189,5 @@ func (m *fileSystemManager) Report() { } func (m *fileSystemManager) shouldRunWithLock() bool { - return m.enabled && m.status != fileOpInProgress && m.database.IsBootstrapped() + return m.enabled && m.status != fileOpInProgress && m.database.IsBootstrappedAndDurable() } diff --git a/src/dbnode/storage/fs_test.go b/src/dbnode/storage/fs_test.go index 9ae349bf1b..1e601b2089 100644 --- a/src/dbnode/storage/fs_test.go +++ b/src/dbnode/storage/fs_test.go @@ -39,10 +39,10 @@ func TestFileSystemManagerShouldRunDuringBootstrap(t *testing.T) { fsm := newFileSystemManager(database, nil, DefaultTestOptions()) mgr := fsm.(*fileSystemManager) - database.EXPECT().IsBootstrapped().Return(false) + database.EXPECT().IsBootstrappedAndDurable().Return(false) require.False(t, mgr.shouldRunWithLock()) - database.EXPECT().IsBootstrapped().Return(true) + database.EXPECT().IsBootstrappedAndDurable().Return(true) require.True(t, mgr.shouldRunWithLock()) } @@ -52,7 +52,7 @@ func TestFileSystemManagerShouldRunWhileRunning(t *testing.T) { database := newMockdatabase(ctrl) fsm := newFileSystemManager(database, nil, DefaultTestOptions()) mgr := fsm.(*fileSystemManager) - database.EXPECT().IsBootstrapped().Return(true) + database.EXPECT().IsBootstrappedAndDurable().Return(true) require.True(t, mgr.shouldRunWithLock()) mgr.status = fileOpInProgress require.False(t, mgr.shouldRunWithLock()) @@ -64,7 +64,7 @@ func TestFileSystemManagerShouldRunEnableDisable(t *testing.T) { database := newMockdatabase(ctrl) fsm := newFileSystemManager(database, nil, DefaultTestOptions()) mgr := fsm.(*fileSystemManager) - database.EXPECT().IsBootstrapped().Return(true).AnyTimes() + database.EXPECT().IsBootstrappedAndDurable().Return(true).AnyTimes() require.True(t, mgr.shouldRunWithLock()) require.NotEqual(t, fileOpInProgress, mgr.Disable()) require.False(t, mgr.shouldRunWithLock()) @@ -76,7 +76,7 @@ func TestFileSystemManagerRun(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() database := newMockdatabase(ctrl) - database.EXPECT().IsBootstrapped().Return(true).AnyTimes() + database.EXPECT().IsBootstrappedAndDurable().Return(true).AnyTimes() fm := NewMockdatabaseFlushManager(ctrl) cm := NewMockdatabaseCleanupManager(ctrl)