Skip to content

Commit

Permalink
kvserver: sync cluster version setting to store
Browse files Browse the repository at this point in the history
Writes to a RocksDB `storage.Engine` were not sync'ed by default,
meaning that they can get lost due to an ill-timed crash. They are now,
matching pebble's behavior. This affects only WriteClusterVersion,
updateBootstrapInfoLocked, WriteLastUpTimestamp, and Compactor.Suggest,
nonw of which are performance sensitive.

Fixes cockroachdb#54906.

(The backport will take care of cockroachdb#54908).

Release note (bug fix): a rare scenario in which a node would refuse
to start after updating the binary was fixed. The log message would
indicate: "store [...], last used with cockroach version [...], is too
old for running version [...] (which requires data from [...] or
later)".
  • Loading branch information
tbg committed Oct 13, 2020
1 parent 22c2db2 commit 8afd061
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions c-deps/libroach/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ DBStatus DBImpl::AssertPreClose() {

DBStatus DBImpl::Put(DBKey key, DBSlice value) {
rocksdb::WriteOptions options;
options.sync = true;
return ToDBStatus(rep->Put(options, EncodeKey(key), ToSlice(value)));
}

DBStatus DBImpl::Merge(DBKey key, DBSlice value) {
rocksdb::WriteOptions options;
options.sync = true;
return ToDBStatus(rep->Merge(options, EncodeKey(key), ToSlice(value)));
}

Expand All @@ -152,16 +154,19 @@ DBStatus DBImpl::Get(DBKey key, DBString* value) {

DBStatus DBImpl::Delete(DBKey key) {
rocksdb::WriteOptions options;
options.sync = true;
return ToDBStatus(rep->Delete(options, EncodeKey(key)));
}

DBStatus DBImpl::SingleDelete(DBKey key) {
rocksdb::WriteOptions options;
options.sync = true;
return ToDBStatus(rep->SingleDelete(options, EncodeKey(key)));
}

DBStatus DBImpl::DeleteRange(DBKey start, DBKey end) {
rocksdb::WriteOptions options;
options.sync = true;
return ToDBStatus(
rep->DeleteRange(options, rep->DefaultColumnFamily(), EncodeKey(start), EncodeKey(end)));
}
Expand Down

0 comments on commit 8afd061

Please sign in to comment.