Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert getRepositoryData only on master node #67806

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,12 @@ RepositoryData repositoryData() {

@Override
public void getRepositoryData(ActionListener<RepositoryData> listener) {
// RepositoryData is the responsibility of the elected master: we shouldn't be loading it on other nodes as we don't have good
// consistency guarantees there, but electedness is too ephemeral to assert. We can say for sure that this node should be
// master-eligible, which is almost as strong since all other snapshot-related activity happens on data nodes whether they be
// master-eligible or not.
assert clusterService.localNode().isMasterNode() : "should only load repository data on master nodes";

if (latestKnownRepoGen.get() == RepositoryData.CORRUPTED_REPO_GEN) {
listener.onFailure(corruptedStateException(null));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ private static ClusterService mockClusterService(ClusterState initialState) {
when(clusterService.getClusterApplierService()).thenReturn(clusterApplierService);
// Setting local node as master so it may update the repository metadata in the cluster state
final DiscoveryNode localNode = new DiscoveryNode("", buildNewFakeTransportAddress(), Version.CURRENT);
when(clusterService.localNode()).thenReturn(localNode);
final AtomicReference<ClusterState> currentState = new AtomicReference<>(
ClusterState.builder(initialState).nodes(
DiscoveryNodes.builder().add(localNode).masterNodeId(localNode.getId()).localNodeId(localNode.getId()).build()).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public void testFilesStoredInThePersistentCacheAreMarkedAsReusedInRecoveryState(
assertThat(repository, instanceOf(BlobStoreRepository.class));
final BlobStoreRepository blobStoreRepository = (BlobStoreRepository) repository;

final RepositoryData repositoryData = ESBlobStoreRepositoryIntegTestCase.getRepositoryData(repository);
final RepositoryData repositoryData = ESBlobStoreRepositoryIntegTestCase.getRepositoryData(
internalCluster().getCurrentMasterNodeInstance(RepositoriesService.class).repository(fsRepoName)
);
final IndexId indexId = repositoryData.resolveIndexId(indexName);
long inMemoryCacheSize = 0;
long expectedPhysicalCacheSize = 0;
Expand Down