From eca54045729d7b660d7eda1f4abf083a6dd1df1d Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Tue, 12 Feb 2019 11:06:22 -0500 Subject: [PATCH] Fix synchronization in LocalCheckpointTracker#contains (#38755) We are accessing the `CountedBitSet` in `LocalCheckpointTracker#contains` without proper synchronization. Relates #33871 --- .../elasticsearch/index/seqno/LocalCheckpointTracker.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/seqno/LocalCheckpointTracker.java b/server/src/main/java/org/elasticsearch/index/seqno/LocalCheckpointTracker.java index 8249e2600ad..50f4e311c8d 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/LocalCheckpointTracker.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/LocalCheckpointTracker.java @@ -157,11 +157,11 @@ public class LocalCheckpointTracker { return true; } final long bitSetKey = getBitSetKey(seqNo); - final CountedBitSet bitSet; + final int bitSetOffset = seqNoToBitSetOffset(seqNo); synchronized (this) { - bitSet = processedSeqNo.get(bitSetKey); + final CountedBitSet bitSet = processedSeqNo.get(bitSetKey); + return bitSet != null && bitSet.get(bitSetOffset); } - return bitSet != null && bitSet.get(seqNoToBitSetOffset(seqNo)); } /**