Use 'SwitchConnectionFile' language uniformly
This commit is contained in:
parent
b17956fef5
commit
d4578a49d8
|
@ -95,14 +95,14 @@ public:
|
|||
Future<Void> onConnected(); // Returns after a majority of coordination servers are available and have reported a leader. The cluster file therefore is valid, but the database might be unavailable.
|
||||
Reference<ClusterConnectionFile> getConnectionFile();
|
||||
|
||||
// Change the database to use the new connection file, and recreate all pending watches for committed transactions.
|
||||
// Switch the database to use the new connection file, and recreate all pending watches for committed transactions.
|
||||
//
|
||||
// Meant to be used as part of a 'hot standby' solution to switch to the standby. A correct switch will involve
|
||||
// advancing the version on the new cluster sufficiently far that any transaction begun with a read version from the
|
||||
// old cluster will fail to commit. Assuming the above version-advancing is done properly, a call to
|
||||
// changeConnectionFile guarantees that any read with a version from the old cluster will not be attempted on the
|
||||
// switchConnectionFile guarantees that any read with a version from the old cluster will not be attempted on the
|
||||
// new cluster.
|
||||
Future<Void> changeConnectionFile(Reference<ClusterConnectionFile> standby);
|
||||
Future<Void> switchConnectionFile(Reference<ClusterConnectionFile> standby);
|
||||
Future<Void> recreateWatches();
|
||||
|
||||
// private:
|
||||
|
|
|
@ -779,10 +779,10 @@ Future<Void> DatabaseContext::onConnected() {
|
|||
return cluster->onConnected();
|
||||
}
|
||||
|
||||
ACTOR static Future<Void> changeConnectionFileImpl(Reference<ClusterConnectionFile> connFile, DatabaseContext* self) {
|
||||
TEST(true); // Change connection file
|
||||
TraceEvent("ChangeClusterFile")
|
||||
.detail("ClusterFile", connFile->canGetFilename() ? connFile->getFilename() : "")
|
||||
ACTOR static Future<Void> switchConnectionFileImpl(Reference<ClusterConnectionFile> connFile, DatabaseContext* self) {
|
||||
TEST(true); // Switch connection file
|
||||
TraceEvent("SwitchConnectionFile")
|
||||
.detail("ConnectionFile", connFile->canGetFilename() ? connFile->getFilename() : "")
|
||||
.detail("ConnectionString", connFile->getConnectionString().toString());
|
||||
|
||||
// Reset state from former cluster.
|
||||
|
@ -797,16 +797,16 @@ ACTOR static Future<Void> changeConnectionFileImpl(Reference<ClusterConnectionFi
|
|||
loop {
|
||||
tr.setOption(FDBTransactionOptions::READ_LOCK_AWARE);
|
||||
try {
|
||||
TraceEvent("ChangeClusterFileAttemptingGRV");
|
||||
TraceEvent("SwitchConnectionFileAttemptingGRV");
|
||||
Version v = wait(tr.getReadVersion());
|
||||
TraceEvent("ChangeClusterFileGotRV")
|
||||
TraceEvent("SwitchConnectionFileGotRV")
|
||||
.detail("ReadVersion", v)
|
||||
.detail("MinAcceptableReadVersion", self->minAcceptableReadVersion);
|
||||
ASSERT(self->minAcceptableReadVersion != std::numeric_limits<Version>::max());
|
||||
self->recreateWatchesTrigger.trigger();
|
||||
return Void();
|
||||
} catch (Error& e) {
|
||||
TraceEvent("ChangeClusterFileError").detail("Error", e.what());
|
||||
TraceEvent("SwitchConnectionFileError").detail("Error", e.what());
|
||||
wait(tr.onError(e));
|
||||
}
|
||||
}
|
||||
|
@ -817,8 +817,8 @@ Reference<ClusterConnectionFile> DatabaseContext::getConnectionFile() {
|
|||
return cluster->getConnectionFile()->get();
|
||||
}
|
||||
|
||||
Future<Void> DatabaseContext::changeConnectionFile(Reference<ClusterConnectionFile> standby) {
|
||||
return changeConnectionFileImpl(standby, this);
|
||||
Future<Void> DatabaseContext::switchConnectionFile(Reference<ClusterConnectionFile> standby) {
|
||||
return switchConnectionFileImpl(standby, this);
|
||||
}
|
||||
|
||||
Future<Void> DatabaseContext::recreateWatches() {
|
||||
|
|
|
@ -51,8 +51,8 @@ struct DifferentClustersSameRVWorkload : TestWorkload {
|
|||
if (clientId != 0) {
|
||||
return Void();
|
||||
}
|
||||
auto changeConnFileDb = Database::createDatabase(cx->getConnectionFile(), -1);
|
||||
std::vector<Future<Void>> clients = { readerClientSeparateDBs(cx, this), doSwitch(changeConnFileDb, this),
|
||||
auto switchConnFileDb = Database::createDatabase(cx->getConnectionFile(), -1);
|
||||
std::vector<Future<Void>> clients = { readerClientSeparateDBs(cx, this), doSwitch(switchConnFileDb, this),
|
||||
writerClient(cx, this), writerClient(extraDB, this) };
|
||||
return success(timeout(waitForAll(clients), testDuration));
|
||||
}
|
||||
|
@ -130,9 +130,9 @@ struct DifferentClustersSameRVWorkload : TestWorkload {
|
|||
TraceEvent("DifferentClusters_CopiedDatabase");
|
||||
wait(advanceVersion(self->extraDB, rv));
|
||||
TraceEvent("DifferentClusters_AdvancedVersion");
|
||||
wait(cx->changeConnectionFile(Reference<ClusterConnectionFile>(
|
||||
wait(cx->switchConnectionFile(Reference<ClusterConnectionFile>(
|
||||
new ClusterConnectionFile(self->extraDB->getConnectionFile()->getConnectionString()))));
|
||||
TraceEvent("DifferentClusters_ChangedConnectionFile");
|
||||
TraceEvent("DifferentClusters_SwitchdConnectionFile");
|
||||
state Transaction tr(cx);
|
||||
tr.setVersion(rv);
|
||||
tr.setOption(FDBTransactionOptions::READ_LOCK_AWARE);
|
||||
|
@ -145,7 +145,7 @@ struct DifferentClustersSameRVWorkload : TestWorkload {
|
|||
TraceEvent("DifferentClusters_ReadError").error(e);
|
||||
wait(tr.onError(e));
|
||||
}
|
||||
// In an actual switch we would call changeConnectionFile after unlocking the database. But it's possible
|
||||
// In an actual switch we would call switchConnectionFile after unlocking the database. But it's possible
|
||||
// that a storage server serves a read at |rv| even after the recovery caused by unlocking the database, and we
|
||||
// want to make that more likely for this test. So read at |rv| then unlock.
|
||||
wait(unlockDatabase(self->extraDB, lockUid));
|
||||
|
|
Loading…
Reference in New Issue