pnowojski commented on a change in pull request #10049: [FLINK-14544][runtime]
Fixing race condition during task cancellation
URL: https://github.com/apache/flink/pull/10049#discussion_r341104156
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/mailbox/TaskMailboxImplTest.java
##########
@@ -307,4 +309,31 @@ public void
testPutWithPriorityAndReadingFromMainMailbox() throws Exception {
Assert.assertSame(mailB,
taskMailbox.take(TaskMailbox.MIN_PRIORITY));
Assert.assertSame(mailD,
taskMailbox.take(TaskMailbox.MIN_PRIORITY));
}
+
+ /**
+ * Testing that we cannot close while running exclusively.
+ */
+ @Test
+ public void testRunExclusively() throws InterruptedException {
+ CountDownLatch exclusiveCodeStarted = new CountDownLatch(1);
+
+ final int numMails = 100;
+
+ // send 100 mails in an atomic operation
+ new Thread(() ->
+ taskMailbox.runExclusively(() -> {
+ exclusiveCodeStarted.countDown();
+ for (int index = 0; index < numMails; index++) {
+ try {
+ taskMailbox.put(new Mail(() ->
{}, 1, "mailD"));
+ Thread.sleep(10);
Review comment:
nit: `sleep(1)` to bring down the execution time from 1s to 100ms?
nitty nit: `numMails = 10` to further speed up the test? 10ms should be
enough to trigger race conditions.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services