Skip to content

Commit

Permalink
shouldRollGeneration should execute under read lock (#41696)
Browse files Browse the repository at this point in the history
Translog#shouldRollGeneration should execute under the read lock since
it accesses the current writer.
  • Loading branch information
dnhatn committed May 10, 2019
1 parent 2a8a64d commit 809ed3b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit 809ed3b

Please sign in to comment.