diff --git a/server/src/main/java/org/elasticsearch/gateway/MetaDataStateFormat.java b/server/src/main/java/org/elasticsearch/gateway/MetaDataStateFormat.java index f6c190fee0922..0821b176e75e6 100644 --- a/server/src/main/java/org/elasticsearch/gateway/MetaDataStateFormat.java +++ b/server/src/main/java/org/elasticsearch/gateway/MetaDataStateFormat.java @@ -141,9 +141,10 @@ public void close() throws IOException { Path finalPath = stateLocation.resolve(fileName); try { Files.copy(finalStatePath, tmpPath); + IOUtils.fsync(tmpPath, false); // fsync the state file // we are on the same FileSystem / Partition here we can do an atomic move Files.move(tmpPath, finalPath, StandardCopyOption.ATOMIC_MOVE); - IOUtils.fsync(stateLocation, true); // we just fsync the dir here.. + IOUtils.fsync(stateLocation, true); } finally { Files.deleteIfExists(tmpPath); }