diff --git a/server/src/main/java/org/elasticsearch/index/translog/Translog.java b/server/src/main/java/org/elasticsearch/index/translog/Translog.java index b98f0f2b6438d..2faac1cb6671d 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/server/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -1641,6 +1641,9 @@ public TranslogGeneration getMinGenerationForSeqNo(final long seqNo) { * @throws IOException if an I/O exception occurred during any file operations */ public void rollGeneration() throws IOException { + // make sure we move most of the data to disk outside of the writeLock + // in order to reduce the time the lock is held since it's blocking all threads + sync(); try (Releasable ignored = writeLock.acquire()) { try { final TranslogReader reader = current.closeIntoReader();