SchedulePolicy.pauseOnFailure = true not working

I expanded the Money Transfer sample project to include a schedule that starts a Money transfer every 2 seconds as following.

public void scheduleMoneyTransfer(TransactionDetails details) {
  ScheduleSpec specs = ScheduleSpec.newBuilder()
      .setIntervals(List.of(new ScheduleIntervalSpec(Duration.ofSeconds(2))))

  ScheduleActionStartWorkflow action = ScheduleActionStartWorkflow.newBuilder()
              .setWorkflowId("money-transfer-workflow") // Actual ID sample: money-transfer-workflow-2024-05-26T12:22:02Z

  SchedulePolicy policy = SchedulePolicy.newBuilder()
      .setPauseOnFailure(true) // Not working

  Schedule schedule = Schedule.newBuilder()

  ScheduleOptions options = ScheduleOptions.newBuilder()

  scheduleClient.createSchedule(SCHEDULE_NAME, schedule, options);

When I simulated an error in the Deposit step, the workflow itself threw an exception and failed as expected after the Deposit activity reached max retry count.

The schedule isn’t paused though. It keeps spawning new workflows every 2 seconds.

Please let me know if I did something wrong in the configs above.

Should work as expected if you remove

This policy means you can start any number of concurrent workflows and last failure of workflow execution is not available to pause schedule as workflows are not treated sequentially.

Thanks for the explanation. Perhaps, our documentation needs to include this fact as it’s not very intuitive or clear why ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_ALLOW_ALL has anything to do with pause on failure.

If possible, this should be an enhancement :stuck_out_tongue: for the SDK. Although workflow executions are not sequential, we should still be able to detect that errors and pause accordingly.

@tihomir btw, does pauseOnFailure work with any ScheduleOverlapPolicy? Or does it only work if we NEVER set ScheduleOverlapPolicy?