LEEKYE commented on code in PR #35120:
URL: https://github.com/apache/beam/pull/35120#discussion_r2138157867
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/control/ExecutionStateSampler.java:
##########
@@ -357,6 +377,19 @@ private void takeSample(long currentTimeMillis, long
millisSinceLastSample) {
transitionsAtLastSample = transitionsAtThisSample;
} else {
long lullTimeMs = currentTimeMillis - lastTransitionTimeMillis.get();
+
+ try {
+ if (lullTimeMs >
TimeUnit.MINUTES.toMillis(lullTimeMinuteForRestart)) {
+ throw new TimeoutException(
+ String.format(
+ "The ptransform has been stuck for more than %d minutes,
the SDK worker will"
+ + " restart",
+ lullTimeMinuteForRestart));
+ }
+ } catch (TimeoutException e) {
+ LOG.error(e.getMessage());
Review Comment:
> Since you catch the exception and don't rethrow it, this current code just
ends up logging (and not throwing exception/restarting the sdk).
>
> I think that you could change the ExecutionStateSampler constructor to
take in some function to call when this timeout has happened. Then for unit
test you could just pass in some lambda that notifies a completablefuture or
countdownlatch and verify it is called. In the real harness, you could pass in
a function that call System.exit or otherwise ends up terminating the harness.
The new fix just throws a runtime exception directly, but probably a try
catch Timeoutexception then throw runtimeexception for consistency would be
better(?) Personally, I would like not to add function to constructor as what
you mentioned because it would potentially break many other tests that are hard
to fix
--
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]