Skip to content

Commit 5f55955

Browse files
authored
Fix another potential race in the file settings watcher (#90388)
Fix another potential race in the file settings watcher for issue #89500 This backports #90302
1 parent e913f6c commit 5f55955

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
@@ -345,6 +345,7 @@ synchronized void stopWatcher() {
345345
logger.debug("stopping watcher ...");
346346
if (watching()) {
347347
try {
348+
// make sure the watcher thread hits the processing latch correctly
348349
cleanupWatchKeys();
349350
fileUpdateState = null;
350351
watchService.close();
@@ -354,6 +355,8 @@ synchronized void stopWatcher() {
354355
if (watcherThreadLatch != null) {
355356
watcherThreadLatch.await();
356357
}
358+
// the watcher thread might have snuck in behind us and re-created the settings watch again
359+
cleanupWatchKeys();
357360
} catch (IOException e) {
358361
logger.warn("encountered exception while closing watch service", e);
359362
} catch (InterruptedException interruptedException) {

0 commit comments

Comments
 (0)