shouldRollGeneration should execute under read lock (#41696)

Translog#shouldRollGeneration should execute under the read lock since
it accesses the current writer.
This commit is contained in:
Nhat Nguyen 2019-05-10 08:50:55 -04:00
parent 2a8a64d3f1
commit 809ed3b721
1 changed files with 3 additions and 2 deletions

View File

@ -561,9 +561,10 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC
* @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;
}
}
/**