Skip to content

Commit

Permalink
Merge pull request #37214 from ajkr/backport2.1-37102
Browse files Browse the repository at this point in the history
release-2.1: storage: fix possible raft log panic after fsync error
  • Loading branch information
ajkr committed Apr 30, 2019
2 parents df200cb + 0eb7e95 commit dab475d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/storage/engine/rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ func (r *RocksDB) syncLoop() {
s.Lock()

var lastSync time.Time
var err error

for {
for len(s.pending) == 0 && !s.closed {
Expand All @@ -674,8 +675,14 @@ func (r *RocksDB) syncLoop() {

s.Unlock()

var err error
if r.cfg.Dir != "" {
// Linux only guarantees we'll be notified of a writeback error once
// during a sync call. After sync fails once, we cannot rely on any
// future data written to WAL being crash-recoverable. That's because
// any future writes will be appended after a potential corruption in
// the WAL, and RocksDB's recovery terminates upon encountering any
// corruption. So, we must not call `DBSyncWAL` again after it has
// failed once.
if r.cfg.Dir != "" && err == nil {
err = statusToError(C.DBSyncWAL(r.rdb))
lastSync = timeutil.Now()
}
Expand Down

0 comments on commit dab475d

Please sign in to comment.