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.
This commit is contained in:
Nhat Nguyen 2018-03-17 17:43:20 -04:00 committed by GitHub
parent c9749180a1
commit f1029aaad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1515,7 +1515,7 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC
* @return the minimum generation for the sequence number * @return the minimum generation for the sequence number
*/ */
public TranslogGeneration getMinGenerationForSeqNo(final long seqNo) { 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 * 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 * local checkpoint. Immediately after flushing, there will be no such generation, so this minimum generation in this case will