From f1029aaad5b49084aed543db1a7d9c0e60fb7264 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 17 Mar 2018 17:43:20 -0400 Subject: [PATCH] getMinGenerationForSeqNo should acquire read lock (#29126) The method Translog#getMinGenerationForSeqNo does not modify the current translog but only access, it therefore should acquire the readLock instead of writeLock. --- .../main/java/org/elasticsearch/index/translog/Translog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6a32ae14fdd..c34f851195a 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/server/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -1515,7 +1515,7 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC * @return the minimum generation for the sequence number */ public TranslogGeneration getMinGenerationForSeqNo(final long seqNo) { - try (ReleasableLock ignored = writeLock.acquire()) { + try (ReleasableLock ignored = readLock.acquire()) { /* * When flushing, the engine will ask the translog for the minimum generation that could contain any sequence number after the * local checkpoint. Immediately after flushing, there will be no such generation, so this minimum generation in this case will