Skip to content

Commit

Permalink
shouldRollGeneration should execute under read lock (elastic#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 authored and Gurkan Kaymak committed May 27, 2019
1 parent e8d9d00 commit 23b992e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,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 23b992e

Please sign in to comment.