Skip to content

Commit

Permalink
Merge branch 'master' into linasn/bootstrap-profiler
Browse files Browse the repository at this point in the history
* master:
  [dbnode] Fix node serving reads/marked bootstrapped after bootstrap failure (#3088)
  • Loading branch information
soundvibe committed Jan 15, 2021
2 parents d5a85d3 + 6746e4f commit ca10b3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/dbnode/storage/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ func (m *bootstrapManager) Bootstrap() (BootstrapResult, error) {
if currPending {
// New bootstrap calls should now enqueue another pending bootstrap
m.hasPending = false
} else {
m.state = Bootstrapped
}
m.Unlock()

Expand Down Expand Up @@ -188,6 +186,7 @@ func (m *bootstrapManager) Bootstrap() (BootstrapResult, error) {
// across the cluster.
m.Lock()
m.lastBootstrapCompletionTime = xtime.ToUnixNano(m.nowFn())
m.state = Bootstrapped
m.Unlock()
return result, nil
}
Expand Down
10 changes: 8 additions & 2 deletions src/dbnode/storage/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import (
"github.com/m3db/m3/src/x/ident"

"github.com/golang/mock/gomock"
xtest "github.com/m3db/m3/src/x/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

xtest "github.com/m3db/m3/src/x/test"
)

func TestDatabaseBootstrapWithBootstrapError(t *testing.T) {
Expand Down Expand Up @@ -74,7 +75,9 @@ func TestDatabaseBootstrapWithBootstrapError(t *testing.T) {
Return(fmt.Errorf("an error")).
Do(func(ctx context.Context, bootstrapResult bootstrap.NamespaceResult) {
// After returning an error, make sure we don't re-enqueue.
require.Equal(t, Bootstrapping, bsm.state)
bsm.bootstrapFn = func() error {
require.Equal(t, Bootstrapping, bsm.state)
return nil
}
}),
Expand All @@ -83,9 +86,12 @@ func TestDatabaseBootstrapWithBootstrapError(t *testing.T) {
ctx := context.NewContext()
defer ctx.Close()

require.Equal(t, BootstrapNotStarted, bsm.state)

result, err := bsm.Bootstrap()
require.NoError(t, err)

require.NoError(t, err)
require.Equal(t, Bootstrapped, bsm.state)
require.Equal(t, 1, len(result.ErrorsBootstrap))
require.Equal(t, "an error", result.ErrorsBootstrap[0].Error())
}
Expand Down

0 comments on commit ca10b3c

Please sign in to comment.