Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't flush data during bootstrapping #268

Merged
merged 2 commits into from Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions storage/bootstrap.go
Expand Up @@ -72,12 +72,10 @@ type bootstrapManager struct {
newBootstrapFn NewBootstrapFn
state bootstrapState
hasPending bool
fsManager databaseFileSystemManager
}

func newBootstrapManager(
database database,
fsManager databaseFileSystemManager,
) databaseBootstrapManager {
opts := database.Options()
return &bootstrapManager{
Expand All @@ -86,7 +84,6 @@ func newBootstrapManager(
log: opts.InstrumentOptions().Logger(),
nowFn: opts.ClockOptions().NowFn(),
newBootstrapFn: opts.NewBootstrapFn(),
fsManager: fsManager,
}
}

Expand Down Expand Up @@ -187,14 +184,5 @@ func (m *bootstrapManager) bootstrap() error {
xlog.NewLogField("duration", end.Sub(start).String()),
).Info("bootstrap finished")
}

// At this point we have bootstrapped everything between now - retentionPeriod
// and now, so we should run the filesystem manager to clean up files and flush
// all the data we bootstrapped.
rateLimitOpts := m.fsManager.RateLimitOptions()
m.fsManager.SetRateLimitOptions(rateLimitOpts.SetLimitEnabled(false))
m.fsManager.Run(m.nowFn(), false)
m.fsManager.SetRateLimitOptions(rateLimitOpts)

return multiErr.FinalError()
}
10 changes: 2 additions & 8 deletions storage/bootstrap_test.go
Expand Up @@ -25,7 +25,6 @@ import (
"testing"
"time"

"github.com/m3db/m3db/ratelimit"
"github.com/m3db/m3db/storage/bootstrap"
"github.com/m3db/m3db/ts"

Expand Down Expand Up @@ -55,12 +54,7 @@ func TestDatabaseBootstrapWithBootstrapError(t *testing.T) {
}

db := &mockDatabase{namespaces: namespaces, opts: opts}
rateLimitOpts := ratelimit.NewOptions()
fsm := NewMockdatabaseFileSystemManager(ctrl)
fsm.EXPECT().RateLimitOptions().Return(rateLimitOpts)
fsm.EXPECT().Run(now, false)
fsm.EXPECT().SetRateLimitOptions(gomock.Any()).Times(2)
bsm := newBootstrapManager(db, fsm).(*bootstrapManager)
bsm := newBootstrapManager(db).(*bootstrapManager)
err := bsm.Bootstrap()

require.NotNil(t, err)
Expand Down Expand Up @@ -89,7 +83,7 @@ func TestDatabaseBootstrapTargetRanges(t *testing.T) {

db := &mockDatabase{opts: opts}

bsm := newBootstrapManager(db, nil).(*bootstrapManager)
bsm := newBootstrapManager(db).(*bootstrapManager)
ranges := bsm.targetRanges(now)

var all [][]time.Time
Expand Down
2 changes: 1 addition & 1 deletion storage/database.go
Expand Up @@ -206,7 +206,7 @@ func NewDatabase(
}
d.fsm = fsm

d.bsm = newBootstrapManager(d, d.fsm)
d.bsm = newBootstrapManager(d)

if opts.RepairEnabled() {
d.repairer, err = newDatabaseRepairer(d)
Expand Down
2 changes: 1 addition & 1 deletion storage/database_test.go
Expand Up @@ -113,7 +113,7 @@ func newTestDatabase(t *testing.T, bs bootstrapState) *db {
database, err := NewDatabase(nil, nil, opts)
require.NoError(t, err)
d := database.(*db)
bsm := newBootstrapManager(d, nil).(*bootstrapManager)
bsm := newBootstrapManager(d).(*bootstrapManager)
bsm.state = bs
d.bsm = bsm
return d
Expand Down