refine code according to comments

This commit is contained in:
chaoguang 2020-01-09 15:42:21 -08:00
parent 941ee6d9f9
commit 1cdb22c4a4
3 changed files with 9 additions and 8 deletions

View File

@ -2685,15 +2685,15 @@ ACTOR static Future<Void> tryCommit( Database cx, Reference<TransactionLogInfo>
tr->info.conflictingKeysRYW = std::make_shared<ReadYourWritesTransaction>(tr->getDatabase());
// To make the getRange call local, we need to explicitly set the read version here.
// This version number 100 set here does nothing but prevent getting read version from the proxy
tr->info.conflictingKeysRYW.get()->setVersion(100);
tr->info.conflictingKeysRYW->setVersion(100);
// Clear the whole key space, thus, RYWTr knows to only read keys locally
tr->info.conflictingKeysRYW.get()->clear(normalKeys);
tr->info.conflictingKeysRYW->clear(normalKeys);
// in case system keys are conflicting
tr->info.conflictingKeysRYW.get()->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->info.conflictingKeysRYW.get()->clear(systemKeys);
tr->info.conflictingKeysRYW->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->info.conflictingKeysRYW->clear(systemKeys);
for (auto const & kr : ci.conflictingKeyRanges.get()) {
tr->info.conflictingKeysRYW.get()->set(kr.begin, conflictingKeysTrue);
tr->info.conflictingKeysRYW.get()->set(kr.end, conflictingKeysFalse);
tr->info.conflictingKeysRYW->set(kr.begin, conflictingKeysTrue);
tr->info.conflictingKeysRYW->set(kr.end, conflictingKeysFalse);
}
}

View File

@ -149,7 +149,7 @@ struct TransactionInfo {
// shared_ptr used here since TransactionInfo is sometimes copied as function parameters.
std::shared_ptr<ReadYourWritesTransaction> conflictingKeysRYW;
explicit TransactionInfo( TaskPriority taskID ) : taskID(taskID), useProvisionalProxies(false), conflictingKeysRYW(nullptr) {}
explicit TransactionInfo( TaskPriority taskID ) : taskID(taskID), useProvisionalProxies(false) {}
};
struct TransactionLogInfo : public ReferenceCounted<TransactionLogInfo>, NonCopyable {

View File

@ -1300,7 +1300,8 @@ Future< Standalone<RangeResultRef> > ReadYourWritesTransaction::getRange(
begin.setKey(beginConflictingKey);
end.setKey(endConflictingKey);
if (tr.info.conflictingKeysRYW) {
Future<Standalone<RangeResultRef>> resultWithKeyPrefixFuture = tr.info.conflictingKeysRYW.get()->getRange(begin, end, limits, snapshot, reverse);
Future<Standalone<RangeResultRef>> resultWithKeyPrefixFuture =
tr.info.conflictingKeysRYW->getRange(begin, end, limits, snapshot, reverse);
// Make sure it happens locally
ASSERT(resultWithKeyPrefixFuture.isReady());
return resultWithKeyPrefixFuture.get();