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

storage: Sync to disk before returning in WaitForApplication #35626

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/storage/stores_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage/engine"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/retry"
)
Expand Down Expand Up @@ -102,7 +103,18 @@ func (is Server) WaitForApplication(
leaseAppliedIndex := repl.mu.state.LeaseAppliedIndex
repl.mu.RUnlock()
if leaseAppliedIndex >= req.LeaseIndex {
return nil
// For performance reasons, we don't sync to disk when
// applying raft commands. This means that if a node restarts
// after applying but before the next sync, its
// LeaseAppliedIndex could temporarily regress (until it
// reapplies its latest raft log entries).
//
// Merging relies on the monotonicity of the log applied
// index, so before returning ensure that rocksdb has synced
// everything up to this point to disk.
//
// https://github.com/cockroachdb/cockroach/issues/33120
return engine.WriteSyncNoop(ctx, s.engine)
}
}
if ctx.Err() == nil {
Expand Down