From b6e6a8c090590aaa77fa5816014a62ee8565af63 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 17 Jun 2020 08:01:35 -0600 Subject: [PATCH] Fix replication operation transient retry test (#58205) After the work to retry transient replication failures, the local and global checkpoint test metadata can be incremented on a different thread than the test thread. This appears to introduce an extremely rare scenario where this data is not visible for later test assertions. This commit fixes the issue by using synchronized maps. --- .../action/support/replication/ReplicationOperationTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java index 45778056337..1c072fa0784 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java @@ -561,8 +561,8 @@ public class ReplicationOperationTests extends ESTestCase { final long maxSeqNoOfUpdatesOrDeletes; final Supplier replicationGroupSupplier; final PendingReplicationActions pendingReplicationActions; - final Map knownLocalCheckpoints = new HashMap<>(); - final Map knownGlobalCheckpoints = new HashMap<>(); + final Map knownLocalCheckpoints = Collections.synchronizedMap(new HashMap<>()); + final Map knownGlobalCheckpoints = Collections.synchronizedMap(new HashMap<>()); TestPrimary(ShardRouting routing, Supplier replicationGroupSupplier, ThreadPool threadPool) { this.routing = routing;