From 659f25bc2f86667df7de19f152921200c7cff7ad Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Tue, 30 Apr 2019 12:39:14 -0400 Subject: [PATCH] shouldRollGeneration should execute under read lock --- .../main/java/org/elasticsearch/index/translog/Translog.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 841201b321549..5e07c43ff6925 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/server/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -561,9 +561,10 @@ public Location add(final Operation operation) throws IOException { * @return {@code true} if the current generation should be rolled to a new generation */ public boolean shouldRollGeneration() { - final long size = this.current.sizeInBytes(); final long threshold = this.indexSettings.getGenerationThresholdSize().getBytes(); - return size > threshold; + try (ReleasableLock ignored = readLock.acquire()) { + return this.current.sizeInBytes() > threshold; + } } /**