Fixing granule opening after not deleting granule locks

This commit is contained in:
Josh Slocum 2022-02-14 13:20:54 -06:00
parent b5ff2006b2
commit abdbc5aafb
1 changed files with 8 additions and 5 deletions

View File

@ -382,6 +382,7 @@ ACTOR Future<Void> updateGranuleSplitState(Transaction* tr,
// FIXME: appears change feed destroy isn't working! ADD BACK // FIXME: appears change feed destroy isn't working! ADD BACK
// wait(updateChangeFeed(tr, KeyRef(parentGranuleID.toString()), ChangeFeedStatus::CHANGE_FEED_DESTROY)); // wait(updateChangeFeed(tr, KeyRef(parentGranuleID.toString()), ChangeFeedStatus::CHANGE_FEED_DESTROY));
Key oldGranuleLockKey = blobGranuleLockKeyFor(parentGranuleRange); Key oldGranuleLockKey = blobGranuleLockKeyFor(parentGranuleRange);
// FIXME: deleting granule lock can cause races where another granule with the same range starts way later // FIXME: deleting granule lock can cause races where another granule with the same range starts way later
// and thinks it can own the granule! Need to change file cleanup to destroy these, if there is no more // and thinks it can own the granule! Need to change file cleanup to destroy these, if there is no more
@ -417,16 +418,19 @@ ACTOR Future<Void> updateGranuleSplitState(Transaction* tr,
return Void(); return Void();
} }
// returns the split state for a given granule on granule reassignment. Assumes granule is in fact splitting, by the // Returns the split state for a given granule on granule reassignment, or unknown if it doesn't exist (meaning the
// presence of the previous granule's lock key // granule splitting finished)
ACTOR Future<std::pair<BlobGranuleSplitState, Version>> getGranuleSplitState(Transaction* tr, ACTOR Future<std::pair<BlobGranuleSplitState, Version>> getGranuleSplitState(Transaction* tr,
UID parentGranuleID, UID parentGranuleID,
UID currentGranuleID) { UID currentGranuleID) {
Key myStateKey = blobGranuleSplitKeyFor(parentGranuleID, currentGranuleID); Key myStateKey = blobGranuleSplitKeyFor(parentGranuleID, currentGranuleID);
Optional<Value> st = wait(tr->get(myStateKey)); Optional<Value> st = wait(tr->get(myStateKey));
ASSERT(st.present()); if (st.present()) {
return decodeBlobGranuleSplitValue(st.get()); return decodeBlobGranuleSplitValue(st.get());
} else {
return std::pair(BlobGranuleSplitState::Unknown, invalidVersion);
}
} }
// writeDelta file writes speculatively in the common case to optimize throughput. It creates the s3 object even though // writeDelta file writes speculatively in the common case to optimize throughput. It creates the s3 object even though
@ -2626,7 +2630,6 @@ ACTOR Future<GranuleStartState> openGranule(Reference<BlobWorkerData> bwData, As
// will be set later // will be set later
} else { } else {
// this sub-granule is done splitting, no need for split logic. // this sub-granule is done splitting, no need for split logic.
ASSERT(granuleSplitState.first == BlobGranuleSplitState::Done);
info.parentGranule.reset(); info.parentGranule.reset();
} }
} }