[BACKPORT] Make reloading the owned partitions in map service context thread safe #11475
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.
Since the migration finalizations can be called concurrently, the
owned partitions might be reloaded concurrently. This means that the
set of owned partitions first might be set to a newer version and
then to an older version, leading to an incorrect set of owned
partitions.
This affects the query engine when it performs queries off the
partition thread as every member reports its own set of owned
partitions which is in this case incorrect. If the results from the
actual partition owner are received by the query engine later than
from the "lying" partition owner, they are discarded. This can cause
the query engine to return incorrect results until the partitions are
reloaded again on an another migration.
The fix reloads the partitions in a CAS loop ensuring that the newest
partition state will always be applied.
Also, added some type parameters and improved javadoc.
Backport of: #11471
Fixes :
#10107
#9870
#10776