using std::vector instead of VectorRef to avoid unknown arena change behavior

This commit is contained in:
chaoguang 2020-01-16 13:06:36 -08:00
parent 0749a5a1ab
commit 30b9858cf5
3 changed files with 6 additions and 5 deletions

View File

@ -104,7 +104,7 @@ struct CommitID {
Version version; // returns invalidVersion if transaction conflicts
uint16_t txnBatchId;
Optional<Value> metadataVersion;
Optional<Standalone<VectorRef<int>>> conflictingKeyRanges;
Optional<std::vector<int>> conflictingKeyRanges;
template <class Ar>
void serialize(Ar& ar) {
@ -112,7 +112,7 @@ struct CommitID {
}
CommitID() : version(invalidVersion), txnBatchId(0) {}
CommitID( Version version, uint16_t txnBatchId, const Optional<Value>& metadataVersion, const Optional<Standalone<VectorRef<int>>>& conflictingKeyRanges = Optional<Standalone<VectorRef<int>>>() ) : version(version), txnBatchId(txnBatchId), metadataVersion(metadataVersion), conflictingKeyRanges(conflictingKeyRanges) {}
CommitID( Version version, uint16_t txnBatchId, const Optional<Value>& metadataVersion, const Optional<std::vector<int>>& conflictingKeyRanges = Optional<std::vector<int>>() ) : version(version), txnBatchId(txnBatchId), metadataVersion(metadataVersion), conflictingKeyRanges(conflictingKeyRanges) {}
};
struct CommitTransactionRequest : TimedRequest {

View File

@ -2691,6 +2691,7 @@ ACTOR static Future<Void> tryCommit( Database cx, Reference<TransactionLogInfo>
// in case system keys are conflicting
tr->info.conflictingKeysRYW->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->info.conflictingKeysRYW->clear(systemKeys);
// merge duplicate indices
const auto cKRs = ci.conflictingKeyRanges.get();
std::set<int> mergedIds(cKRs.begin(), cKRs.end());
for (auto const & rCRIndex : mergedIds) {

View File

@ -1034,15 +1034,15 @@ ACTOR Future<Void> commitBatch(
else {
// If enable the option to report conflicting keys from resolvers, we union all conflicting key ranges here and send back through CommitID
if (trs[t].transaction.report_conflicting_keys) {
Standalone<VectorRef<int>> conflictingEntryIds;
std::vector<int> conflictingEntryIds;
for (int resolverInd : transactionResolverMap[t]) {
for (auto const & rCRIndex : resolution[resolverInd].conflictingKeyRangeMap[nextTr[resolverInd]]){
conflictingEntryIds.push_back(conflictingEntryIds.arena(), rCRIndex);
conflictingEntryIds.emplace_back(rCRIndex);
}
}
// At least one keyRange index should be returned
ASSERT(conflictingEntryIds.size());
trs[t].reply.send(CommitID(invalidVersion, t, Optional<Value>(), Optional<Standalone<VectorRef<int>>>(conflictingEntryIds)));
trs[t].reply.send(CommitID(invalidVersion, t, Optional<Value>(), Optional<std::vector<int>>(conflictingEntryIds)));
} else {
trs[t].reply.sendError(not_committed());
}