Skip to content
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 @@ -94,6 +94,7 @@
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -4223,11 +4224,12 @@ private void checkAborted() {
final long uploadTimeInMillis = threadPool.rawRelativeTimeInMillis() - startMillis;
blobStoreSnapshotMetrics.incrementCountersForPartUpload(partBytes, uploadTimeInMillis);
logger.trace(
"[{}] Writing [{}] of size [{}b] to [{}] took [{}ms]",
"[{}] Writing [{}] of size [{}b] to [{}] took [{}/{}ms]",
Copy link
Copy Markdown
Contributor Author

@joshua-adams-1 joshua-adams-1 Nov 7, 2025

Choose a reason for hiding this comment

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

Improving the log. Example: ...took [1.4s/1400ms]

metadata.name(),
partName,
partBytes,
shardContainer.path(),
new TimeValue(uploadTimeInMillis),
uploadTimeInMillis
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class SnapshotShutdownProgressTracker {
);

private static final Logger logger = LogManager.getLogger(SnapshotShutdownProgressTracker.class);
private static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("strict_date_optional_time");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using the same approach as here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I haven't delved into the possibilities, but looking at the superficial outcome a log message from the testing you added looks like

[2025-11-11T02:25:35,945][INFO ][o.e.s.SnapshotShutdownProgressTracker][testTrackerPauseTimestamp] Current active shard snapshot stats on data node [local-node-id-for-test]. Node shutdown cluster state update received at [1970-01-01T00:00:00.000Z]. Finished signalling shard snapshots to pause at [1970-01-01T00:00:00.000Z]. Time between the node shutdown cluster state update and signalling shard snapshots to pause is [0 millis]Number shard snapshots running [0]. Number shard snapshots waiting for master node reply to status update request [0] Shard snapshot completion stats since shutdown began: Done [0]; Failed [0]; Aborted [0]; Paused [0]

Specifically, [1970-01-01T00:00:00.000Z]. Is there any way to get a UTC label on this so we know (without looking at the code) what timezone is being reported?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

N.B I used DateFormatter.formatMillis() here which uses UTC as a default

N.B The Z at the end is actually the result of ZoneOffset.UTC.toString(). However, this isn't very user friendly so I have changed the log message to read:

... Node shutdown cluster state update received at [1970-01-01T00:00:00.000Z UTC] ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works for me, thanks 👍


private final Supplier<String> getLocalNodeId;
private final Consumer<Logger> logIndexShardSnapshotStatuses;
Expand Down Expand Up @@ -136,15 +138,17 @@ private void logProgressReport() {
logger.info(
"""
Current active shard snapshot stats on data node [{}]. \
Node shutdown cluster state update received at [{} millis]. \
Finished signalling shard snapshots to pause at [{} millis]. \
Node shutdown cluster state update received at [{} UTC]. \
Finished signalling shard snapshots to pause at [{} UTC]. \
Time between the node shutdown cluster state update and signalling shard snapshots to pause is [{} millis]. \
Number shard snapshots running [{}]. \
Number shard snapshots waiting for master node reply to status update request [{}] \
Shard snapshot completion stats since shutdown began: Done [{}]; Failed [{}]; Aborted [{}]; Paused [{}]\
""",
getLocalNodeId.get(),
shutdownStartMillis,
shutdownFinishedSignallingPausingMillis,
DATE_TIME_FORMATTER.formatMillis(shutdownStartMillis),
DATE_TIME_FORMATTER.formatMillis(shutdownFinishedSignallingPausingMillis),
shutdownFinishedSignallingPausingMillis - shutdownStartMillis,
numberOfShardSnapshotsInProgressOnDataNode.get(),
shardSnapshotRequests.size(),
doneCount.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.concurrent.DeterministicTaskQueue;
import org.elasticsearch.core.TimeValue;
Expand Down Expand Up @@ -271,12 +272,15 @@ public void testTrackerPauseTimestamp() {
);

try (var mockLog = MockLog.capture(Coordinator.class, SnapshotShutdownProgressTracker.class)) {
long timeInMillis = testThreadPool.relativeTimeInMillis();
mockLog.addExpectation(
new MockLog.SeenEventExpectation(
"pausing timestamp should be set",
SnapshotShutdownProgressTracker.class.getName(),
Level.INFO,
"*Finished signalling shard snapshots to pause at [" + testThreadPool.relativeTimeInMillis() + " millis]*"
"*Finished signalling shard snapshots to pause at ["
+ DateFormatter.forPattern("strict_date_optional_time").formatMillis(timeInMillis)
+ " UTC]*"
)
);

Expand Down