Fix Overly Strict Assertion in BlobStoreRepository (#63061) (#63236)

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:
Armin Braun 2020-10-05 14:06:57 +02:00 committed by GitHub
parent 8c4503bcc3
commit d13c1f5058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -404,6 +404,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
public void updateState(ClusterState state) { public void updateState(ClusterState state) {
metadata = getRepoMetadata(state); metadata = getRepoMetadata(state);
uncleanStart = uncleanStart && metadata.generation() != metadata.pendingGeneration(); uncleanStart = uncleanStart && metadata.generation() != metadata.pendingGeneration();
final boolean wasBestEffortConsistency = bestEffortConsistency;
bestEffortConsistency = uncleanStart || isReadOnly() bestEffortConsistency = uncleanStart || isReadOnly()
|| state.nodes().getMinNodeVersion().before(RepositoryMetadata.REPO_GEN_IN_CS_VERSION) || state.nodes().getMinNodeVersion().before(RepositoryMetadata.REPO_GEN_IN_CS_VERSION)
|| metadata.generation() == RepositoryData.UNKNOWN_REPO_GEN || ALLOW_CONCURRENT_MODIFICATION.get(metadata.settings()); || metadata.generation() == RepositoryData.UNKNOWN_REPO_GEN || ALLOW_CONCURRENT_MODIFICATION.get(metadata.settings());
@ -430,8 +431,9 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
} else { } else {
final long previousBest = latestKnownRepoGen.getAndSet(metadata.generation()); final long previousBest = latestKnownRepoGen.getAndSet(metadata.generation());
if (previousBest != metadata.generation()) { if (previousBest != metadata.generation()) {
assert metadata.generation() == RepositoryData.CORRUPTED_REPO_GEN || previousBest < metadata.generation() : assert wasBestEffortConsistency || metadata.generation() == RepositoryData.CORRUPTED_REPO_GEN
"Illegal move from repository generation [" + previousBest + "] to generation [" + metadata.generation() + "]"; || previousBest < metadata.generation() : "Illegal move from repository generation [" + previousBest
+ "] to generation [" + metadata.generation() + "]";
logger.debug("Updated repository generation from [{}] to [{}]", previousBest, metadata.generation()); logger.debug("Updated repository generation from [{}] to [{}]", previousBest, metadata.generation());
} }
} }