Skip to content

Commit

Permalink
Fixing SkewedReadWrite to load its metadata in a transactionally cons…
Browse files Browse the repository at this point in the history
…istent way (#9274)
  • Loading branch information
sfc-gh-jslocum authored and jzhou77 committed Feb 15, 2023
1 parent e2c2375 commit 2983dfe
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions fdbserver/workloads/SkewedReadWrite.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,26 @@ struct SkewedReadWriteWorkload : ReadWriteCommon {
}

ACTOR static Future<Void> updateServerShards(Database cx, SkewedReadWriteWorkload* self) {
state Future<RangeResult> serverList =
runRYWTransaction(cx, [](Reference<ReadYourWritesTransaction> tr) -> Future<RangeResult> {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
return tr->getRange(serverListKeys, CLIENT_KNOBS->TOO_MANY);
});
state RangeResult range =
wait(runRYWTransaction(cx, [](Reference<ReadYourWritesTransaction> tr) -> Future<RangeResult> {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
return tr->getRange(serverKeysRange, CLIENT_KNOBS->TOO_MANY);
}));
wait(success(serverList));
state RangeResult serverList;
state RangeResult range;
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
loop {
// read in transaction to ensure two key ranges are transactionally consistent
try {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
state Future<RangeResult> serverListF = tr->getRange(serverListKeys, CLIENT_KNOBS->TOO_MANY);
state Future<RangeResult> rangeF = tr->getRange(serverKeysRange, CLIENT_KNOBS->TOO_MANY);
wait(store(serverList, serverListF));
wait(store(range, rangeF));
break;
} catch (Error& e) {
wait(tr->onError(e));
}
}
// decode server interfaces
self->serverInterfaces.clear();
for (int i = 0; i < serverList.get().size(); i++) {
auto ssi = decodeServerListValue(serverList.get()[i].value);
for (int i = 0; i < serverList.size(); i++) {
auto ssi = decodeServerListValue(serverList[i].value);
self->serverInterfaces.emplace(ssi.id(), ssi);
}
// clear self->serverShards
Expand Down

0 comments on commit 2983dfe

Please sign in to comment.