It is useful to know if a Run is in a retry or on the first run. For example, imagine a step method that makes an API call to create an external resource. That step method could fail during the "execution" stage such that the API call was successful, but the run errors while trying to close the transaction or update the Run record. In this case, the job will be retried and re-run this step method.
We can add another API call as a guard to check if the resource already exists in the external system, but on the first run of the job, this is guaranteed not to be the case (presuming the job is setup properly to be idempotent). We could save the API call on the first run and only check in subsequent runs, if we knew whether the run was a first run or not.
It is useful to know if a Run is in a retry or on the first run. For example, imagine a step method that makes an API call to create an external resource. That step method could fail during the "execution" stage such that the API call was successful, but the run errors while trying to close the transaction or update the Run record. In this case, the job will be retried and re-run this step method.
We can add another API call as a guard to check if the resource already exists in the external system, but on the first run of the job, this is guaranteed not to be the case (presuming the job is setup properly to be idempotent). We could save the API call on the first run and only check in subsequent runs, if we knew whether the run was a first run or not.