Skip to content

Commit

Permalink
fix: a storage server does not ever need to rollback before a version…
Browse files Browse the repository at this point in the history
… restored from disk
  • Loading branch information
etschannen committed Nov 30, 2017
1 parent e5a6829 commit 7f72aa7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fdbserver/storageserver.actor.cpp
Expand Up @@ -313,7 +313,7 @@ struct StorageServer {
CoalescedKeyRangeMap< Version > newestDirtyVersion; // Similar to newestAvailableVersion, but includes (only) keys that were only partly available (due to cancelled fetchKeys)

// The following are in rough order from newest to oldest
Version lastTLogVersion, lastVersionWithData;
Version lastTLogVersion, lastVersionWithData, restoredVersion;
NotifiedVersion version;
NotifiedVersion desiredOldestVersion; // We can increase oldestVersion (and then durableVersion) to this version when the disk permits
NotifiedVersion oldestVersion; // See also storageVersion()
Expand Down Expand Up @@ -416,7 +416,7 @@ struct StorageServer {
StorageServer(IKeyValueStore* storage, Reference<AsyncVar<ServerDBInfo>> const& db, StorageServerInterface const& ssi)
: instanceID(g_random->randomUniqueID().first()),
storage(this, storage), db(db),
lastTLogVersion(0), lastVersionWithData(0),
lastTLogVersion(0), lastVersionWithData(0), restoredVersion(0),
updateEagerReads(0),
shardChangeCounter(0),
fetchKeysParallelismLock(SERVER_KNOBS->FETCH_KEYS_PARALLELISM_BYTES),
Expand Down Expand Up @@ -458,6 +458,7 @@ struct StorageServer {
oldestVersion = ver;
durableVersion = ver;
lastVersionWithData = ver;
restoredVersion = ver;

mutableData().createNewVersion(ver);
mutableData().forgetVersionsBefore(ver);
Expand Down Expand Up @@ -2186,7 +2187,7 @@ bool containsRollback( VersionUpdateRef const& changes, Version& rollbackVersion

class StorageUpdater {
public:
StorageUpdater(Version fromVersion, Version newOldestVersion) : fromVersion(fromVersion), newOldestVersion(newOldestVersion), currentVersion(fromVersion), processedStartKey(false) {}
StorageUpdater(Version fromVersion, Version newOldestVersion, Version restoredVersion) : fromVersion(fromVersion), newOldestVersion(newOldestVersion), currentVersion(fromVersion), restoredVersion(restoredVersion), processedStartKey(false) {}

void applyMutation(StorageServer* data, MutationRef const& m, Version ver) {
//TraceEvent("SSNewVersion", data->thisServerID).detail("VerWas", data->mutableData().latestVersion).detail("ChVer", ver);
Expand Down Expand Up @@ -2216,6 +2217,7 @@ class StorageUpdater {
Version currentVersion;
private:
Version fromVersion;
Version restoredVersion;

KeyRef startKey;
bool nowAssigned;
Expand Down Expand Up @@ -2252,7 +2254,7 @@ class StorageUpdater {
BinaryReader br(m.param2, Unversioned());
br >> rollbackVersion;

if ( rollbackVersion < fromVersion ) {
if ( rollbackVersion < fromVersion && rollbackVersion > restoredVersion) {

This comment has been minimized.

Copy link
@panghy

panghy May 12, 2018

Contributor

@etschannen should this also be a couple lines below? this is only preventing a trace message

TEST( true ); // ShardApplyPrivateData shard rollback
TraceEvent(SevWarn, "Rollback", data->thisServerID)
.detail("FromVersion", fromVersion)
Expand Down Expand Up @@ -2389,7 +2391,7 @@ ACTOR Future<Void> update( StorageServer* data, bool* pReceivedUpdate )
data->updateEagerReads = &eager;
data->debug_inApplyUpdate = true;

StorageUpdater updater(data->lastVersionWithData, std::max( std::max(data->desiredOldestVersion.get(), data->oldestVersion.get()), minNewOldestVersion ));
StorageUpdater updater(data->lastVersionWithData, std::max( std::max(data->desiredOldestVersion.get(), data->oldestVersion.get()), minNewOldestVersion ), data->restoredVersion);

if (EXPENSIVE_VALIDATION) data->data().atLatest().validate();
validate(data);
Expand Down

0 comments on commit 7f72aa7

Please sign in to comment.