How to force an activity retry before the specified retry period?

Hi everyone,

I have a workflow with a few activities, activities, one of them performs polling on a field called status. This activity would then fail whenever the status is different then AVAILABLE. This workflow has the conflict policy set to “Use Existing”.

My polling activity has the following configurations:

  • Initial Interval: 5s
  • Max Interval: 1h
  • Backoff Coefficient​: 2.0
  • Schedule to Close Timeout: 4 days
  • Max retries: Infinite

However, I may have the scenario where my status changes to AVAILABLE within the 1h max interval.

  1. How could I possibility force my running workflow to restart from the last pending activity whenever I request for a new workflow to avoid the need of waiting 1h in the case where my status was updated between retries?
  2. Should I be doing this polling in a different way? Ex: Sleeping my workflow whenever this activity fails. I still want to use the temporal activity retries capability though.
  3. I’m in the pay-as-you-go plan, would I be charged while my workflow is in the “Running” status but waiting for an activity to be retried?

Please, give me as much detailed information as possible since I’m new to Temporal.

Thanks!

You could look into activity reset command via cli and/or code,

Cli:

temporal activity reset -h

Code

service.blockingStub().resetActivity(...);

Do I need to specify the activity or this will retry the current running activity?

You have to specify either activity type or specific activity id. If you specify activity type, all currently pending (running) activities of this type will be reset. So for example:

ResetActivityResponse res =
    service
        .blockingStub()
        .resetActivity(
            ResetActivityRequest.newBuilder()
                .setExecution(
                    WorkflowExecution.newBuilder()
                        .setWorkflowId("<wfid>")
                        .build())
                    .setType("<activity_type>")
                    //.setId("<activity_id>")
                .setNamespace("<namespace_name>")
                .build());

If you specify activity id, then only that activity thats currently pending would be reset.