Skip to content

Commit 3a5bafd

Browse files
Fix race condition in SnapshotMetricsIT.testSnapshotAPMMetrics (#132686)
Moves the new code that updates the snapshot completed metrics to before the snapshot listeners are completed. This mirrors how the listener is completed after the snapshot started metric is updated. Resolves: #132672
1 parent 3afc254 commit 3a5bafd

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,6 @@ tests:
515515
- class: org.elasticsearch.xpack.sql.action.SqlSearchPageTimeoutIT
516516
method: testSearchContextIsCleanedUpAfterPageTimeoutForAggregationQueries
517517
issue: https://github.com/elastic/elasticsearch/issues/132619
518-
- class: org.elasticsearch.repositories.SnapshotMetricsIT
519-
method: testSnapshotAPMMetrics
520-
issue: https://github.com/elastic/elasticsearch/issues/132672
521518
- class: org.elasticsearch.xpack.ml.integration.TextEmbeddingQueryIT
522519
method: testHybridSearch
523520
issue: https://github.com/elastic/elasticsearch/issues/132703

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,6 @@ protected void doRun() {
12321232
() -> snapshotListeners.addListener(new ActionListener<>() {
12331233
@Override
12341234
public void onResponse(List<ActionListener<SnapshotInfo>> actionListeners) {
1235-
SnapshotsServiceUtils.completeListenersIgnoringException(actionListeners, snapshotInfo);
12361235
final Map<String, Object> attributesWithState = Maps.copyMapWithAddedEntry(
12371236
SnapshotMetrics.createAttributesMap(snapshot.getProjectId(), repo.getMetadata()),
12381237
"state",
@@ -1241,6 +1240,7 @@ public void onResponse(List<ActionListener<SnapshotInfo>> actionListeners) {
12411240
snapshotMetrics.snapshotsCompletedCounter().incrementBy(1, attributesWithState);
12421241
snapshotMetrics.snapshotsDurationHistogram()
12431242
.record((snapshotInfo.endTime() - snapshotInfo.startTime()) / 1_000.0, attributesWithState);
1243+
SnapshotsServiceUtils.completeListenersIgnoringException(actionListeners, snapshotInfo);
12441244
logger.info("snapshot [{}] completed with state [{}]", snapshot, snapshotInfo.state());
12451245
}
12461246

0 commit comments

Comments
 (0)