Skip to content

Commit b435bc0

Browse files
Include the snapshot ID when logging shard snapshot statuses (#123654)
The SnapshotShutdownProgressTracker logs the shard snapshot statuses individually and now each status can be associated back to the parent snapshot. Relates ES-10991
1 parent c0c0827 commit b435bc0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public final class SnapshotShardsService extends AbstractLifecycleComponent impl
8787

8888
private final SnapshotShutdownProgressTracker snapshotShutdownProgressTracker;
8989

90+
/** Maps each snapshot to its collection of individual shard snapshots */
9091
private final Map<Snapshot, Map<ShardId, IndexShardSnapshotStatus>> shardSnapshots = new HashMap<>();
9192

9293
// A map of snapshots to the shardIds that we already reported to the master as failed
@@ -237,9 +238,16 @@ public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexSh
237238
}
238239

239240
private void logIndexShardSnapshotStatuses(Logger callerLogger) {
240-
for (var snapshotStatuses : shardSnapshots.values()) {
241-
for (var shardSnapshot : snapshotStatuses.entrySet()) {
242-
callerLogger.info(Strings.format("ShardId %s, %s", shardSnapshot.getKey(), shardSnapshot.getValue()));
241+
for (var snapshot : shardSnapshots.entrySet()) { // iterate the snapshots
242+
for (var shardSnapshot : snapshot.getValue().entrySet()) { // iterate the individual shard snapshots
243+
callerLogger.info(
244+
Strings.format(
245+
"SnapshotId %s, ShardId %s, shard snapshot status: %s",
246+
snapshot.getKey().getSnapshotId(),
247+
shardSnapshot.getKey(),
248+
shardSnapshot.getValue()
249+
)
250+
);
243251
}
244252
}
245253
}

0 commit comments

Comments
 (0)