As long as `bestEffortConsistency` is `true`, the value of `latestKnownRepoGen` can be updated as a result of reads. We can only assert that `latestKnownRepoGen` and cluster state move in lock-step if `bestEffortConsistency` was `false` before updating the metadata generation as well as after. Closes #62877
This commit is contained in:
parent
8c4503bcc3
commit
d13c1f5058
|
@ -404,6 +404,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
public void updateState(ClusterState state) {
|
||||
metadata = getRepoMetadata(state);
|
||||
uncleanStart = uncleanStart && metadata.generation() != metadata.pendingGeneration();
|
||||
final boolean wasBestEffortConsistency = bestEffortConsistency;
|
||||
bestEffortConsistency = uncleanStart || isReadOnly()
|
||||
|| state.nodes().getMinNodeVersion().before(RepositoryMetadata.REPO_GEN_IN_CS_VERSION)
|
||||
|| metadata.generation() == RepositoryData.UNKNOWN_REPO_GEN || ALLOW_CONCURRENT_MODIFICATION.get(metadata.settings());
|
||||
|
@ -430,8 +431,9 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
} else {
|
||||
final long previousBest = latestKnownRepoGen.getAndSet(metadata.generation());
|
||||
if (previousBest != metadata.generation()) {
|
||||
assert metadata.generation() == RepositoryData.CORRUPTED_REPO_GEN || previousBest < metadata.generation() :
|
||||
"Illegal move from repository generation [" + previousBest + "] to generation [" + metadata.generation() + "]";
|
||||
assert wasBestEffortConsistency || metadata.generation() == RepositoryData.CORRUPTED_REPO_GEN
|
||||
|| previousBest < metadata.generation() : "Illegal move from repository generation [" + previousBest
|
||||
+ "] to generation [" + metadata.generation() + "]";
|
||||
logger.debug("Updated repository generation from [{}] to [{}]", previousBest, metadata.generation());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue