Skip to content

Commit 3ab4269

Browse files
authored
Fix another potential race in the file settings watcher (#90302)
Fix another potential race in the file settings watcher for issue #89500 Backports #90302 to 8.5
1 parent 1a96011 commit 3ab4269

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/changelog/90302.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 90302
2+
summary: Fix another potential race in the file settings watcher
3+
area: Infra/Core
4+
type: bug
5+
issues: [89500]

server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ synchronized void stopWatcher() {
341341
logger.debug("stopping watcher ...");
342342
if (watching()) {
343343
try {
344+
// make sure the watcher thread hits the processing latch correctly
344345
cleanupWatchKeys();
345346
fileUpdateState = null;
346347
watchService.close();
@@ -350,6 +351,8 @@ synchronized void stopWatcher() {
350351
if (watcherThreadLatch != null) {
351352
watcherThreadLatch.await();
352353
}
354+
// the watcher thread might have snuck in behind us and re-created the settings watch again
355+
cleanupWatchKeys();
353356
} catch (IOException e) {
354357
logger.warn("encountered exception while closing watch service", e);
355358
} catch (InterruptedException interruptedException) {

0 commit comments

Comments
 (0)