scwhittle commented on code in PR #39666:
URL: https://github.com/apache/beam/pull/39666#discussion_r3747694159
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java:
##########
@@ -590,12 +594,29 @@ private void
switchStreamingWorkerHarness(ConnectivityType connectivityType) {
LOG.info("Started new StreamingWorkerStatusPages instance.");
}
+ @VisibleForTesting
+ boolean isHealthy() {
+ int stuckCommitDurationMillis =
+ options.isEnableStreamingEngine() ?
Math.max(options.getStuckCommitDurationMillis(), 0) : 0;
+ if (stuckCommitDurationMillis <= 0) {
+ return true;
Review Comment:
nit: how about nesting the loop under an if stuckCommitsDuration > 0,
instead of the early return true. Then we can add other things that return
false if it's unhealthy and not accidentally skip them.
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/streaming/ActiveWorkStateTest.java:
##########
@@ -319,25 +318,19 @@ public void
testCurrentActiveWorkBudget_correctlyAggregatesActiveWorkBudget_mult
}
@Test
- public void testInvalidateStuckCommits() {
- Map<ShardedKey, WorkId> invalidatedCommits = new HashMap<>();
+ public void testHasStuckCommits() {
ShardedKey shardedKey1 = shardedKey("someKey", 1L);
ShardedKey shardedKey2 = shardedKey("anotherKey", 2L);
ExecutableWork stuckWork1 = expiredWork(createWorkItem(1L, 1L,
shardedKey1));
stuckWork1.work().setState(Work.State.COMMITTING);
- ExecutableWork stuckWork2 = expiredWork(createWorkItem(2L, 1L,
shardedKey2));
- stuckWork2.work().setState(Work.State.COMMITTING);
+ ExecutableWork unstuckWork2 = expiredWork(createWorkItem(2L, 1L,
shardedKey2));
+ unstuckWork2.work().setState(Work.State.PROCESSING);
activeWorkState.activateWorkForKey(stuckWork1);
- activeWorkState.activateWorkForKey(stuckWork2);
+ activeWorkState.activateWorkForKey(unstuckWork2);
- activeWorkState.invalidateStuckCommits(Instant.now(),
invalidatedCommits::put);
-
- assertThat(invalidatedCommits).containsEntry(shardedKey1, stuckWork1.id());
- assertThat(invalidatedCommits).containsEntry(shardedKey2, stuckWork2.id());
- verify(computationStateCache).invalidate(shardedKey1.key(),
shardedKey1.shardingKey());
- verify(computationStateCache).invalidate(shardedKey2.key(),
shardedKey2.shardingKey());
+ assertThat(activeWorkState.hasStuckCommits(Instant.now())).isTrue();
Review Comment:
validate it is false with timestamp closer to start procesisng timestamp
--
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]