Fix feed fetch and lock race

This commit is contained in:
Josh Slocum 2023-03-01 10:37:54 -06:00
parent 7dc6de7aee
commit 546a8879c2
1 changed files with 6 additions and 5 deletions

View File

@ -7323,11 +7323,12 @@ ACTOR Future<std::unordered_map<Key, Version>> dispatchChangeFeeds(StorageServer
}
for (auto& feedId : newFeedIds) {
auto feedIt = data->uidChangeFeed.find(feedId);
// we just read the change feed data map earlier in fetchKeys without yielding, so these feeds must exist
ASSERT(feedIt != data->uidChangeFeed.end());
ASSERT(!feedIt->second->removing);
ReadOptions fetchReadOptions = readOptionsForFeedFetch(readOptions, keys, feedIt->second->range);
feedFetches[feedIt->second->id] = fetchChangeFeed(data, feedIt->second, 0, endVersion, fetchReadOptions);
// feed may have been moved away or deleted while we took the feed lock, do nothing in that case
if (feedIt != data->uidChangeFeed.end() && !feedIt->second->removing) {
ReadOptions fetchReadOptions = readOptionsForFeedFetch(readOptions, keys, feedIt->second->range);
feedFetches[feedIt->second->id] =
fetchChangeFeed(data, feedIt->second, 0, endVersion, fetchReadOptions);
}
}
loop {