amoghrajesh commented on code in PR #77015:
URL: https://github.com/apache/airflow/pull/77015#discussion_r4663885266


##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -225,6 +249,32 @@ def persist_job_id(self, context: Context, external_id: 
JsonValue) -> None:
             external_id=external_id,
         )
 
+    def resume_failed_job(self, external_id: JsonValue, status: str, context: 
Context) -> JsonValue | None:
+        """
+        Ask the external system to resume a failed job from where it stopped, 
instead of starting over.
+
+        Called on a retry when the stored job is in a terminal failed state. 
Return the ID to poll,
+        which may be the same ID (for example a Databricks run repaired in 
place) or a new one. Return
+        ``None`` to submit a fresh job, which is the default.
+
+        Only called when ``resume_on_retry`` is set. A cleared task reaches it 
only when the clear kept
+        task state, because clearing otherwise discards the stored ID.
+        """
+        return None
+
+    def _resume_failed_job_safely(self, external_id: JsonValue, status: str, 
context: Context) -> JsonValue:
+        try:
+            return self.resume_failed_job(external_id, status, context)
+        except Exception:
+            # A failed resume must never leave a retry worse off than 
resubmitting.

Review Comment:
   Moved into this PR. When the resume raises, the mixin reads the stored job's 
status up to 3 times, 10s apart, and watches it if it is running or succeeded. 
If the status can't be read, the try fails instead of submitting. Note: this 
only catches a job resumed under the stored id, which covers Databricks repair.



-- 
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]

Reply via email to