add PrimaryRegion boolean
This commit is contained in:
parent
e321044310
commit
09f77a785f
|
@ -493,8 +493,8 @@ Future<ConfigurationResult> changeConfig(Reference<DB> db, std::map<std::string,
|
|||
// the caller need to reset the perpetual wiggle stats in case the reset txn on DD side is cancelled
|
||||
// due to DD can die at the same time
|
||||
if (newConfig.perpetualStorageWiggleSpeed == 0 && oldConfig.perpetualStorageWiggleSpeed == 1) {
|
||||
wait(resetStorageWiggleMetrics(tr, true));
|
||||
wait(resetStorageWiggleMetrics(tr, false));
|
||||
wait(resetStorageWiggleMetrics(tr, PrimaryRegion(true)));
|
||||
wait(resetStorageWiggleMetrics(tr, PrimaryRegion(false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#if defined(NO_INTELLISENSE) && !defined(FDBCLIENT_STORAGEWIGGLEMETRICS_ACTOR_G_H)
|
||||
#define FDBCLIENT_STORAGEWIGGLEMETRICS_ACTOR_G_H
|
||||
#include "fdbclient/StorageWiggleMetrics.actor.g.h"
|
||||
|
@ -30,6 +31,8 @@
|
|||
#include "fdbclient/Status.h"
|
||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||
|
||||
FDB_DECLARE_BOOLEAN_PARAM(PrimaryRegion);
|
||||
|
||||
struct StorageWiggleMetrics {
|
||||
constexpr static FileIdentifier file_identifier = 4728961;
|
||||
|
||||
|
@ -95,7 +98,7 @@ struct StorageWiggleMetrics {
|
|||
|
||||
// read from DB
|
||||
ACTOR template <typename TxnType>
|
||||
Future<Optional<StorageWiggleMetrics>> loadStorageWiggleMetrics(TxnType tr, bool primary) {
|
||||
Future<Optional<StorageWiggleMetrics>> loadStorageWiggleMetrics(TxnType tr, PrimaryRegion primary) {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::READ_LOCK_AWARE);
|
||||
auto f = tr->get(perpetualStorageWiggleStatsPrefix.withSuffix(primary ? "primary"_sr : "remote"_sr));
|
||||
|
@ -108,7 +111,7 @@ Future<Optional<StorageWiggleMetrics>> loadStorageWiggleMetrics(TxnType tr, bool
|
|||
|
||||
// update the serialized metrics when the perpetual wiggle is enabled
|
||||
ACTOR template <typename TxnType>
|
||||
Future<Void> updateStorageWiggleMetrics(TxnType tr, StorageWiggleMetrics metrics, bool primary) {
|
||||
Future<Void> updateStorageWiggleMetrics(TxnType tr, StorageWiggleMetrics metrics, PrimaryRegion primary) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
auto f = tr->get(perpetualStorageWiggleKey);
|
||||
|
@ -122,7 +125,7 @@ Future<Void> updateStorageWiggleMetrics(TxnType tr, StorageWiggleMetrics metrics
|
|||
|
||||
// set all fields except for smoothed durations to default values
|
||||
ACTOR template <class TrType>
|
||||
Future<Void> resetStorageWiggleMetrics(TrType tr, bool primary) {
|
||||
Future<Void> resetStorageWiggleMetrics(TrType tr, PrimaryRegion primary) {
|
||||
state Optional<StorageWiggleMetrics> metrics = wait(loadStorageWiggleMetrics(tr, primary));
|
||||
if (metrics.present()) {
|
||||
auto oldStepDuration = metrics.get().smoothed_wiggle_duration;
|
||||
|
|
|
@ -185,8 +185,8 @@ Future<Void> StorageWiggler::resetStats() {
|
|||
metrics = newMetrics;
|
||||
return runRYWTransaction(teamCollection->dbContext(),
|
||||
[this, &newMetrics](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
|
||||
return updateStorageWiggleMetrics(tr, newMetrics, teamCollection->isPrimary());
|
||||
});
|
||||
return updateStorageWiggleMetrics(tr, newMetrics, PrimaryRegion(teamCollection->isPrimary()));
|
||||
});
|
||||
}
|
||||
|
||||
Future<Void> StorageWiggler::restoreStats() {
|
||||
|
@ -200,7 +200,7 @@ Future<Void> StorageWiggler::restoreStats() {
|
|||
auto readFuture =
|
||||
runRYWTransaction(teamCollection->dbContext(),
|
||||
[this](Reference<ReadYourWritesTransaction> tr) -> Future<Optional<StorageWiggleMetrics>> {
|
||||
return loadStorageWiggleMetrics(tr, teamCollection->isPrimary());
|
||||
return loadStorageWiggleMetrics(tr, PrimaryRegion(teamCollection->isPrimary()));
|
||||
});
|
||||
return map(readFuture, assignFunc);
|
||||
}
|
||||
|
@ -212,8 +212,8 @@ Future<Void> StorageWiggler::startWiggle() {
|
|||
}
|
||||
return runRYWTransaction(teamCollection->dbContext(),
|
||||
[this](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
|
||||
return updateStorageWiggleMetrics(tr, metrics, teamCollection->isPrimary());
|
||||
});
|
||||
return updateStorageWiggleMetrics(tr, metrics, PrimaryRegion(teamCollection->isPrimary()));
|
||||
});
|
||||
}
|
||||
|
||||
Future<Void> StorageWiggler::finishWiggle() {
|
||||
|
@ -230,8 +230,8 @@ Future<Void> StorageWiggler::finishWiggle() {
|
|||
}
|
||||
return runRYWTransaction(teamCollection->dbContext(),
|
||||
[this](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
|
||||
return updateStorageWiggleMetrics(tr, metrics, teamCollection->isPrimary());
|
||||
});
|
||||
return updateStorageWiggleMetrics(tr, metrics, PrimaryRegion(teamCollection->isPrimary()));
|
||||
});
|
||||
}
|
||||
|
||||
ACTOR Future<Void> remoteRecovered(Reference<AsyncVar<ServerDBInfo> const> db) {
|
||||
|
|
|
@ -2843,8 +2843,8 @@ ACTOR Future<std::pair<Optional<StorageWiggleMetrics>, Optional<StorageWiggleMet
|
|||
if (use_system_priority) {
|
||||
tr->setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE);
|
||||
}
|
||||
wait(store(primaryV, loadStorageWiggleMetrics(tr, true)) &&
|
||||
store(remoteV, loadStorageWiggleMetrics(tr, false)));
|
||||
wait(store(primaryV, loadStorageWiggleMetrics(tr, PrimaryRegion(true))) &&
|
||||
store(remoteV, loadStorageWiggleMetrics(tr, PrimaryRegion(false))));
|
||||
return std::make_pair(primaryV, remoteV);
|
||||
} catch (Error& e) {
|
||||
wait(tr->onError(e));
|
||||
|
|
Loading…
Reference in New Issue