FR:Init StagingKey when created

The key field was used in various places, such as figuring out the conflict key range.
We should not leave it empty
This commit is contained in:
Meng Xu 2020-09-09 16:12:28 -07:00
parent 5c5abd7afa
commit ce92f1a224
3 changed files with 6 additions and 6 deletions

View File

@ -478,7 +478,7 @@ ACTOR static Future<Void> applyStagingKeysBatch(std::map<Key, StagingKey>::itera
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
state int sets = 0;
state int clears = 0;
state Key endKey = begin->second.key;
state Key endKey = begin->first;
TraceEvent(SevFRDebugInfo, "FastRestoreApplierPhaseApplyStagingKeysBatch", applierID).detail("Begin", begin->first);
loop {
try {
@ -508,7 +508,7 @@ ACTOR static Future<Void> applyStagingKeysBatch(std::map<Key, StagingKey>::itera
} else {
ASSERT(false);
}
endKey = iter != end ? iter->second.key : endKey;
endKey = iter != end ? iter->first : endKey;
iter++;
if (sets > 10000000 || clears > 10000000) {
TraceEvent(SevError, "FastRestoreApplierPhaseApplyStagingKeysBatchInfiniteLoop", applierID)

View File

@ -54,7 +54,7 @@ struct StagingKey {
LogMessageVersion version; // largest version of set or clear for the key
std::map<LogMessageVersion, Standalone<MutationRef>> pendingMutations; // mutations not set or clear type
explicit StagingKey() : version(0), type(MutationRef::MAX_ATOMIC_OP) {}
explicit StagingKey(Key key) : key(key), version(0), type(MutationRef::MAX_ATOMIC_OP) {}
// Add mutation m at newVersion to stagingKey
// Assume: SetVersionstampedKey and SetVersionstampedValue have been converted to set
@ -294,7 +294,7 @@ struct ApplierBatchData : public ReferenceCounted<ApplierBatchData> {
void addMutation(MutationRef m, LogMessageVersion ver) {
if (!isRangeMutation(m)) {
auto item = stagingKeys.emplace(m.param1, StagingKey());
auto item = stagingKeys.emplace(m.param1, StagingKey(m.param1));
item.first->second.add(m, ver);
} else {
stagingKeyRanges.insert(StagingKeyRange(m, ver));

View File

@ -39,8 +39,8 @@
#define SevFRMutationInfo SevVerbose
//#define SevFRMutationInfo SevInfo
//#define SevFRDebugInfo SevVerbose
#define SevFRDebugInfo SevInfo
#define SevFRDebugInfo SevVerbose
//#define SevFRDebugInfo SevInfo
struct VersionedMutation {
MutationRef mutation;