diff --git a/fdb-record-layer-lucene/src/test/java/com/apple/foundationdb/record/lucene/directory/PendingWriteQueueIntegrationTest.java b/fdb-record-layer-lucene/src/test/java/com/apple/foundationdb/record/lucene/directory/PendingWriteQueueIntegrationTest.java index ed484b74c1..4a0cd52dd1 100644 --- a/fdb-record-layer-lucene/src/test/java/com/apple/foundationdb/record/lucene/directory/PendingWriteQueueIntegrationTest.java +++ b/fdb-record-layer-lucene/src/test/java/com/apple/foundationdb/record/lucene/directory/PendingWriteQueueIntegrationTest.java @@ -816,11 +816,14 @@ void testConcurrentMixedOperations(boolean withMerge) { snooze(10); // increase the chances of concurrency commit(context); } - if (threadId == 2 && withMerge) { - mergeIndexNow(schemaSetup, index); - } }); + // Merge the index outside the loop, as the merge will clear the pending writes flag and may cause conflicts + // on the index + if (withMerge) { + mergeIndexNow(schemaSetup, index); + } + // Verify operation counts assertEquals(10, insertCount.get()); // 5 threads * 2 inserts assertEquals(5, updateCount.get()); // 5 threads * 1 update (DELETE+INSERT in queue)