Skip to content

Commit

Permalink
Fix race in RecoveryRequestTrackerTests (#59187)
Browse files Browse the repository at this point in the history
Currently in the recovery request tracker tests we place the futures
into the future map on the GENERIC thread. It is possible that the test
has already advanced past the point where we block on these futures
before they are placed in the map. This introduces other potential
failures as we expect all futures have been completed. This commit fixes
the test by places the futures in the map prior to dispatching.
  • Loading branch information
Tim-Brooks committed Jul 7, 2020
1 parent 2e71db7 commit b1c3ad8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public void testIdempotencyIsEnforced() {
final long seqNo = j;
int iterations = randomIntBetween(2, 5);
for (int i = 0; i < iterations; ++i) {
PlainActionFuture<Void> future = PlainActionFuture.newFuture();
Set<PlainActionFuture<Void>> set = seqToResult.computeIfAbsent(seqNo, (k) -> ConcurrentCollections.newConcurrentSet());
set.add(future);
threadPool.generic().execute(() -> {
PlainActionFuture<Void> future = PlainActionFuture.newFuture();
ActionListener<Void> listener = requestTracker.markReceivedAndCreateListener(seqNo, future);
Set<PlainActionFuture<Void>> set = seqToResult.computeIfAbsent(seqNo, (k) -> ConcurrentCollections.newConcurrentSet());
set.add(future);
if (listener != null) {
boolean added = seqNosReturned.add(seqNo);
// Ensure that we only return 1 future per sequence number
Expand Down

0 comments on commit b1c3ad8

Please sign in to comment.