scwhittle commented on code in PR #37104:
URL: https://github.com/apache/beam/pull/37104#discussion_r2618895796
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/windmill/client/commits/StreamingEngineWorkCommitterTest.java:
##########
@@ -400,4 +415,57 @@ public void testMultipleCommitSendersSingleStream() {
workCommitter.stop();
}
+
+ @Test
+ public void testStop_drainsCommitQueue_concurrentCommit() throws
InterruptedException {
+ Set<CompleteCommit> completeCommits = Collections.newSetFromMap(new
ConcurrentHashMap<>());
+ workCommitter =
+ StreamingEngineWorkCommitter.builder()
+ // Set the semaphore to only allow a single commit at a time.
+ // This creates a bottleneck on purpose to trigger race conditions
during shutdown.
+ .setCommitByteSemaphore(WeightedSemaphore.create(1, (commit) -> 1))
+ .setCommitWorkStreamFactory(commitWorkStreamFactory)
+ .setOnCommitComplete(completeCommits::add)
+ .build();
+
+ int numThreads = 5;
+ ExecutorService producer = Executors.newFixedThreadPool(numThreads);
+ AtomicBoolean producing = new AtomicBoolean(true);
+ AtomicLong sentCommits = new AtomicLong(0);
+
+ workCommitter.start();
+
+ AtomicLong workToken = new AtomicLong(0);
+ for (int i = 0; i < numThreads; i++) {
+ @SuppressWarnings("FutureReturnValueIgnored")
+ Future<?> unused =
Review Comment:
instead of ignoring, how about joining all of these at the end of the test?
That also verifies these threads don't get stuck somewhere calling commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]