Avoid race between ConfigNodeImpl::getChanges and ConfigNodeImpl::commitMutations

This commit is contained in:
sfc-gh-tclinkenbeard 2022-12-04 12:47:00 -08:00 committed by Lukas Joswiak
parent 6f70fc243b
commit 728d1294fa
2 changed files with 7 additions and 0 deletions

View File

@ -113,6 +113,7 @@ TEST_CASE("/fdbserver/ConfigDB/ConfigNode/Internal/versionedMutationKeyOrdering"
class ConfigNodeImpl {
UID id;
FlowLock lock;
OnDemandStore kvStore;
CounterCollection cc;
@ -218,6 +219,8 @@ class ConfigNodeImpl {
}
ACTOR static Future<Void> getChanges(ConfigNodeImpl* self, ConfigFollowerGetChangesRequest req) {
wait(self->lock.take());
state FlowLock::Releaser releaser(self->lock);
Version lastCompactedVersion = wait(getLastCompactedVersion(self));
if (req.lastSeenVersion < lastCompactedVersion) {
++self->failedChangeRequests;
@ -413,6 +416,8 @@ class ConfigNodeImpl {
Standalone<VectorRef<VersionedConfigCommitAnnotationRef>> annotations,
Version commitVersion,
Version liveVersion = ::invalidVersion) {
wait(self->lock.take());
state FlowLock::Releaser releaser(self->lock);
Version latestVersion = 0;
int index = 0;
for (const auto& mutation : mutations) {

View File

@ -111,6 +111,8 @@ class SimpleConfigConsumerImpl {
if (e.code() == error_code_version_already_compacted) {
CODE_PROBE(true, "SimpleConfigConsumer get version_already_compacted error");
wait(getSnapshotAndChanges(self, broadcaster));
} else if (e.code() == error_code_broken_promise) {
CODE_PROBE(true, "SimpleConfigConsumer::fetchChanges retrying on broken promise");
} else {
throw e;
}