Skip to content

Commit ba46bd4

Browse files
Avoid noisy exceptions on data nodes when aborting snapshots (#88476)
Currently, an abort (especially when triggered an index delete) can manifest as either an aborted snapshot exception, a missing index exception or an NPE. The latter two show up as noise in logs. This change catches effectively all of these cleanly as aborted snapshot exceptions so they don't get logged as warnings and avoids the NPE if a shard was removed from the index service concurrently by using the API that throws on missing shards to look it up.
1 parent 84af493 commit ba46bd4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,10 @@ private void snapshot(
337337
ActionListener<ShardSnapshotResult> listener
338338
) {
339339
try {
340-
final IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).getShardOrNull(shardId.id());
340+
if (snapshotStatus.isAborted()) {
341+
throw new AbortedSnapshotException();
342+
}
343+
final IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).getShard(shardId.id());
341344
if (indexShard.routingEntry().primary() == false) {
342345
throw new IndexShardSnapshotFailedException(shardId, "snapshot should be performed only on primary");
343346
}

0 commit comments

Comments
 (0)