Skip to content

Commit

Permalink
db: code comment about guaranteeing durability of initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeerbhola committed Dec 19, 2023
1 parent 5c5ad7e commit 40d5f21
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions open.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,17 @@ func GetVersion(dir string, fs vfs.FS) (string, error) {
return version, nil
}

// replayWAL replays the edits in the specified log file. If the DB is in
// read only mode, then the WALs are replayed into memtables and not flushed. If
// the DB is not in read only mode, then the contents of the WAL are guaranteed
// to be flushed.
// replayWAL replays the edits in the specified log file. If the DB is in read
// only mode, then the WALs are replayed into memtables and not flushed. If
// the DB is not in read only mode, then the contents of the WAL are
// guaranteed to be flushed. Note that this flushing is very important for
// guaranteeing durability: the application may have had a number of pending
// fsyncs to the WAL before the process crashed, and those fsyncs may not have
// happened but the corresponding data may now be readable from the WAL (while
// sitting in write-back caches in the kernel or the storage device). By
// reading the WAL (including the non-fsynced data) and then flushing all
// these changes (flush does fsyncs), we are able to guarantee that the
// initial state of the DB is durable.
//
// The toFlush return value is a list of flushables associated with the WAL
// being replayed which will be flushed. Once the version edit has been applied
Expand Down

0 comments on commit 40d5f21

Please sign in to comment.