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

Skip sending ShardActiveRequest checks in stateless nodes #121387

Merged
merged 3 commits into from
Feb 6, 2025
Merged
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 @@ -229,6 +229,11 @@ private void deleteShardIfExistElseWhere(
long clusterStateVersion,
IndexShardRoutingTable indexShardRoutingTable
) {
if (DiscoveryNode.isStateless(clusterService.getSettings())) {
deleteShardStoreOnApplierThread(indexShardRoutingTable.shardId(), clusterStateVersion);
return;
}

List<Tuple<DiscoveryNode, ShardActiveRequest>> requests = new ArrayList<>(indexShardRoutingTable.size());
String indexUUID = indexShardRoutingTable.shardId().getIndex().getUUID();
for (int copy = 0; copy < indexShardRoutingTable.size(); copy++) {
Expand Down Expand Up @@ -320,34 +325,37 @@ private void allNodesResponded() {
return;
}

clusterService.getClusterApplierService()
.runOnApplierThread("indices_store ([" + shardId + "] active fully on other nodes)", Priority.HIGH, currentState -> {
if (clusterStateVersion != currentState.getVersion()) {
logger.trace(
"not deleting shard {}, the update task state version[{}] is not equal to cluster state before "
+ "shard active api call [{}]",
shardId,
currentState.getVersion(),
clusterStateVersion
);
return;
}
try {
indicesService.deleteShardStore("no longer used", shardId, currentState);
} catch (Exception ex) {
logger.debug(() -> format("%s failed to delete unallocated shard, ignoring", shardId), ex);
}
}, new ActionListener<>() {
@Override
public void onResponse(Void unused) {}

@Override
public void onFailure(Exception e) {
logger.error(() -> format("%s unexpected error during deletion of unallocated shard", shardId), e);
}
});
deleteShardStoreOnApplierThread(shardId, clusterStateVersion);
}
}

private void deleteShardStoreOnApplierThread(ShardId shardId, long clusterStateVersion) {
clusterService.getClusterApplierService()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it wouldn't be necessary to run this on the applier thread, but I wanted to keep the changes minimal.

.runOnApplierThread("indices_store ([" + shardId + "] active fully on other nodes)", Priority.HIGH, currentState -> {
if (clusterStateVersion != currentState.getVersion()) {
logger.trace(
"not deleting shard {}, the update task state version[{}] is not equal to cluster state before "
+ "shard active api call [{}]",
shardId,
currentState.getVersion(),
clusterStateVersion
);
return;
}
try {
indicesService.deleteShardStore("no longer used", shardId, currentState);
} catch (Exception ex) {
logger.debug(() -> format("%s failed to delete unallocated shard, ignoring", shardId), ex);
}
}, new ActionListener<>() {
@Override
public void onResponse(Void unused) {}

@Override
public void onFailure(Exception e) {
logger.error(() -> format("%s unexpected error during deletion of unallocated shard", shardId), e);
}
});
}

private class ShardActiveRequestHandler implements TransportRequestHandler<ShardActiveRequest> {
Expand Down