fix resetStats() bug
This commit is contained in:
parent
09f77a785f
commit
c4d9a81d95
|
@ -123,10 +123,16 @@ Future<Void> updateStorageWiggleMetrics(TxnType tr, StorageWiggleMetrics metrics
|
|||
return Void();
|
||||
}
|
||||
|
||||
// set all fields except for smoothed durations to default values
|
||||
// set all fields except for smoothed durations to default values. If the metrics is not given, load from system key
|
||||
// space
|
||||
ACTOR template <class TrType>
|
||||
Future<Void> resetStorageWiggleMetrics(TrType tr, PrimaryRegion primary) {
|
||||
state Optional<StorageWiggleMetrics> metrics = wait(loadStorageWiggleMetrics(tr, primary));
|
||||
Future<Void> resetStorageWiggleMetrics(TrType tr,
|
||||
PrimaryRegion primary,
|
||||
Optional<StorageWiggleMetrics> metrics = Optional<StorageWiggleMetrics>()) {
|
||||
if (!metrics.present()) {
|
||||
wait(store(metrics, loadStorageWiggleMetrics(tr, primary)));
|
||||
}
|
||||
|
||||
if (metrics.present()) {
|
||||
auto oldStepDuration = metrics.get().smoothed_wiggle_duration;
|
||||
auto oldRoundDuration = metrics.get().smoothed_round_duration;
|
||||
|
|
|
@ -183,9 +183,9 @@ Future<Void> StorageWiggler::resetStats() {
|
|||
newMetrics.smoothed_round_duration = metrics.smoothed_round_duration;
|
||||
newMetrics.smoothed_wiggle_duration = metrics.smoothed_wiggle_duration;
|
||||
metrics = newMetrics;
|
||||
return runRYWTransaction(teamCollection->dbContext(),
|
||||
[this, &newMetrics](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
|
||||
return updateStorageWiggleMetrics(tr, newMetrics, PrimaryRegion(teamCollection->isPrimary()));
|
||||
return runRYWTransaction(
|
||||
teamCollection->dbContext(), [this](Reference<ReadYourWritesTransaction> tr) -> Future<Void> {
|
||||
return resetStorageWiggleMetrics(tr, PrimaryRegion(teamCollection->isPrimary()), metrics);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue