[
https://issues.apache.org/jira/browse/BEAM-7520?focusedWorklogId=326072&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326072
]
ASF GitHub Bot logged work on BEAM-7520:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Oct/19 02:40
Start Date: 10/Oct/19 02:40
Worklog Time Spent: 10m
Work Description: kennknowles commented on pull request #9190:
[BEAM-7520] Fix timer firing order in DirectRunner
URL: https://github.com/apache/beam/pull/9190#discussion_r333308585
##########
File path:
runners/direct-java/src/test/java/org/apache/beam/runners/direct/DirectRunnerTest.java
##########
@@ -616,6 +649,186 @@ public void processElement(ProcessContext c) {
p.run();
}
+ /**
+ * Test running of {@link Pipeline} which has two {@link POutput POutputs}
and finishing the first
+ * one triggers data being fed into the second one.
+ */
+ @Test(timeout = 10000)
+ public void testTwoPOutputsInPipelineWithCascade() throws
InterruptedException {
+
+ StaticQueue<Integer> start = StaticQueue.of("start", VarIntCoder.of());
+ StaticQueue<Integer> messages = StaticQueue.of("messages",
VarIntCoder.of());
+
+ Pipeline pipeline = getPipeline(false);
+ pipeline.begin().apply("outputStartSignal", outputStartTo(start));
+ PCollection<Integer> result =
+ pipeline
+ .apply("processMessages", messages.read())
+ .apply(
+ Window.<Integer>into(new GlobalWindows())
+ .triggering(AfterWatermark.pastEndOfWindow())
+ .discardingFiredPanes()
+ .withAllowedLateness(Duration.ZERO))
+ .apply(Sum.integersGlobally());
+
+ // the result should be 6, after the data will have been written
+ PAssert.that(result).containsInAnyOrder(6);
+
+ PipelineResult run = pipeline.run();
+
+ // wait until a message has been written to the start queue
+ while (start.take() == null) {}
+
+ // and publish messages
+ messages.add(1).add(2).add(3).terminate();
+
+ run.waitUntilFinish();
+ }
+
+ @Test(timeout = 5000)
+ public void testTwoTimersSettingEachOther() {
+ Pipeline pipeline = getPipeline();
+ Instant now = new Instant(1500000000000L);
+ Instant end = now.plus(100);
+ PCollection<String> result = pipeline.apply(new TwoTimerTest(now, end));
Review comment:
Reading this casually, `TwoTimerTest` is not really clear what is being
tested. The code that creates the output and the code that asserts about the
expectations are very far from each other. Ideally, you would move the
assertion into `TwoTimerTest` somehow. Since `TwoTimerTest` owns the logic, it
also owns the expected output.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 326072)
Time Spent: 10h 20m (was: 10h 10m)
> DirectRunner timers are not strictly time ordered
> -------------------------------------------------
>
> Key: BEAM-7520
> URL: https://issues.apache.org/jira/browse/BEAM-7520
> Project: Beam
> Issue Type: Bug
> Components: runner-direct
> Affects Versions: 2.13.0
> Reporter: Jan Lukavský
> Assignee: Jan Lukavský
> Priority: Major
> Time Spent: 10h 20m
> Remaining Estimate: 0h
>
> Let's suppose we have the following situation:
> - statful ParDo with two timers - timerA and timerB
> - timerA is set for window.maxTimestamp() + 1
> - timerB is set anywhere between <windowStart, windowEnd), let's denote that
> timerB.timestamp
> - input watermark moves to BoundedWindow.TIMESTAMP_MAX_VALUE
> Then the order of timers is as follows (correct):
> - timerB
> - timerA
> But, if timerB sets another timer (say for timerB.timestamp + 1), then the
> order of timers will be:
> - timerB (timerB.timestamp)
> - timerA (BoundedWindow.TIMESTAMP_MAX_VALUE)
> - timerB (timerB.timestamp + 1)
> Which is not ordered by timestamp. The reason for this is that when the input
> watermark update is evaluated, the WatermarkManager,extractFiredTimers() will
> produce both timerA and timerB. That would be correct, but when timerB sets
> another timer, that breaks this.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)