Hello. I am using the Java SDK test environment to run unit tests. We have a workflow which fires off a number of async activities and doesn’t wait for them to finish before closing the workflow. This is our desired behavior as we don’t want them to prevent our workflow from completing if they are still retrying. We have one in particular which we added right before the workflow completes which is causing an issue in our test code.
Occasionally, our test are printing “Failure during reporting of activity result to the server” and “NOT_FOUND: Completed workflow”. My understanding is that the async activity was started, but the workflow completed before the activity completed. This doesn’t happen on every run, so I assume there is some non-deterministic ordering of the executions in the test environment which makes sense for an async execution.
Normally this is not a problem as our test cases pass still, but it causes an issue with time-skipping. We have some tests which call a workflow await path or test failure scenarios which trigger activity retry back offs. When this transient error with the async activity occurs, some subsequent tests are no longer time skipping. Is there an explanation for why the time skipping is stopped and how we can prevent it?
I am using the Java SDK test environment to run unit tests. We have a workflow which fires off a number of async activities and doesn’t wait for them to finish before closing the workflow.
This type of scenario can potentially leave a lot of already canceled basically activities on your sdk workers, filling up your activity executor slots, and causing workers to stop polling for “real” work.
Whats the actual use case here?
Hey tiho thanks for the reply!
We have several activities that we want to fire and forget as to not block the workflow. If we reach the end of the workflow and they are still retrying, we don’t want to wait for them to finish before completing the workflow.
I thought that if we simply closed the workflow we would see the error that the activity failed to report its result, but then the activity executor would be released.
Are you saying the activity executor won’t be released in this scenario? Should we explicitly cancel the activities if we don’t want to wait for them to complete or their retries to expire?
Are you saying the activity executor won’t be released in this scenario?
Yes it will release when your activities try to report completion / failure / or on their next heartbeat.
Danger here is that activity code hangs on something causing that activity executor slot to not be released. This is independent on the activity StartToClose timeout, that is handled on server side.
It’s not a great situation that can cause a lot of damage..thats why not recommending it if possible.
Should we explicitly cancel the activities if we don’t want to wait for them to complete or their retries to expire?
Yes for prod env would consider canceling them and waiting on their cancelation. Note activities have to heartbeat for that..so if thats not possible, alternatively,
Would consider running those activities in child workflow with abandoned child wf policy and close the parent workflow when you need, allowing child wf to complete them. Or before complete parent send signal to child so child can initiate canceling cancellation scope activity are in, wait for cancelation to complete, before completing.
Thanks Tiho! Based on this we will cancel any outstanding activities before completing the workflow.