Skip to content

Commit 43dcca3

Browse files
authored
Fix a racing condition in shard snapshot status update (elastic#130302) (elastic#130368)
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 (cherry picked from commit 6b0d534) # Conflicts: # muted-tests.yml
1 parent 1d68fc2 commit 43dcca3

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
@@ -512,9 +512,6 @@ tests:
512512
- class: org.elasticsearch.test.apmintegration.TracesApmIT
513513
method: testApmIntegration
514514
issue: https://github.com/elastic/elasticsearch/issues/129651
515-
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
516-
method: testSnapshotShutdownProgressTracker
517-
issue: https://github.com/elastic/elasticsearch/issues/129752
518515
- class: org.elasticsearch.xpack.security.SecurityRolesMultiProjectIT
519516
method: testUpdatingFileBasedRoleAffectsAllProjects
520517
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)