IGNITE-23661 Eliminate race in onBeforeApply within StandaloneMetaStorageManager #4723
+15
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/IGNITE-23661
Long story short, the stack trace of a problem is following:
assertTrue(waitForCondition(() -> newLogicalTopology.equals(finalDistributionZoneManager.logicalTopology())
fails becausefinalDistributionZoneManager.logicalTopology()
is not updated becausenotificationFuture
inWatchProcessor#notifyWatches()
is not completed becausenotifyUpdateRevisionFuture
is not completed becauseassert causalityToken > lastCompleteToken
inorg.apache.ignite.internal.causality.IncrementalVersionedValue#completeInternal
isn't matched (but not logged though) becausewatch events are reordered by revision despite the fact that they are properly ordered by timestamp, see
org.apache.ignite.internal.metastorage.server.NotifyWatchProcessorEvent#compareTo
for more details.All in all, order mismatch is a result of non-thread safe
StandaloneMetaStorageManager
. BothonBeforeApply
and command processing within listener should be thread-safe. That's why there's a race between operation safeTime assignment and revision calculation. onBeforeApply is guarded by group specific monitor, preciselysynchronized (groupIdSyncMonitor(request.groupId()))
See
ActionRequestProcessor.handleRequestInternal
for more details. Command processing on its turn is expected to be processed under raft umbrella, meaning in single-thread environment.And corresponding synchronisation was missed in
StandaloneMetaStorageManager
.