Skip to content

Commit 6b0d534

Browse files
authored
Fix a racing condition in shard snapshot status update (elastic#130302)
The enqueued task can run before the code reaches the status update line. When it happens, the status update can set the status backwards. This PR fixes it by moving the status update before enqueuing the task. Resolves: elastic#129752
1 parent fe75f8d commit 6b0d534

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
@@ -524,9 +524,6 @@ tests:
524524
- class: org.elasticsearch.search.query.VectorIT
525525
method: testFilteredQueryStrategy
526526
issue: https://github.com/elastic/elasticsearch/issues/129517
527-
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
528-
method: testSnapshotShutdownProgressTracker
529-
issue: https://github.com/elastic/elasticsearch/issues/129752
530527
- class: org.elasticsearch.xpack.security.SecurityRolesMultiProjectIT
531528
method: testUpdatingFileBasedRoleAffectsAllProjects
532529
issue: https://github.com/elastic/elasticsearch/issues/129775

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ private void startNewShardSnapshots(String localNodeId, SnapshotsInProgress.Entr
411411
entry.version(),
412412
entry.startTime()
413413
);
414+
snapshotStatus.updateStatusDescription("shard snapshot enqueuing to start");
414415
startShardSnapshotTaskRunner.enqueueTask(new ActionListener<>() {
415416
@Override
416417
public void onResponse(Releasable releasable) {
@@ -429,7 +430,6 @@ public void onFailure(Exception e) {
429430
assert false : wrapperException; // impossible
430431
}
431432
});
432-
snapshotStatus.updateStatusDescription("shard snapshot enqueued to start");
433433
}
434434

435435
// apply some backpressure by reserving one SNAPSHOT thread for the startup work

0 commit comments

Comments
 (0)