|
37 | 37 | LOGGER = logging.getLogger("airbyte") |
38 | 38 | _NO_TIMEOUT = timedelta.max |
39 | 39 | _API_SIDE_RUNNING_STATUS = {AsyncJobStatus.RUNNING, AsyncJobStatus.TIMED_OUT} |
| 40 | +_ASYNC_JOB_TERMINAL_FAILURE_MESSAGE = "Async job failed after exhausting all retry attempts." |
| 41 | +_ASYNC_JOB_FINAL_FAILURE_MESSAGE = "Async job partition did not complete successfully." |
40 | 42 |
|
41 | 43 |
|
42 | 44 | class AsyncPartition: |
@@ -487,11 +489,16 @@ def _process_partitions_with_errors(self, partition: AsyncPartition) -> None: |
487 | 489 | AirbyteTracedException: If at least one job could not be completed. |
488 | 490 | """ |
489 | 491 | status_by_job_id = {job.api_job_id(): job.status() for job in partition.jobs} |
| 492 | + failure_type = ( |
| 493 | + FailureType.system_error |
| 494 | + if any(job.is_creation_failure() for job in partition.jobs) |
| 495 | + else FailureType.transient_error |
| 496 | + ) |
490 | 497 | self._non_breaking_exceptions.append( |
491 | 498 | AirbyteTracedException( |
492 | | - message="Async job failed after exhausting all retry attempts.", |
| 499 | + message=_ASYNC_JOB_TERMINAL_FAILURE_MESSAGE, |
493 | 500 | internal_message=f"At least one job could not be completed for slice {partition.stream_slice}. Job statuses were: {status_by_job_id}. See warning logs for more information.", |
494 | | - failure_type=FailureType.system_error, |
| 501 | + failure_type=failure_type, |
495 | 502 | ) |
496 | 503 | ) |
497 | 504 |
|
@@ -536,15 +543,25 @@ def create_and_get_completed_partitions(self) -> Iterable[AsyncPartition]: |
536 | 543 | if self._non_breaking_exceptions: |
537 | 544 | # We emitted traced message but we didn't break on non_breaking_exception. We still need to raise an exception so that the |
538 | 545 | # call of `create_and_get_completed_partitions` knows that there was an issue with some partitions and the sync is incomplete. |
| 546 | + failure_type = ( |
| 547 | + FailureType.transient_error |
| 548 | + if any( |
| 549 | + isinstance(exception, AirbyteTracedException) |
| 550 | + and exception.message == _ASYNC_JOB_TERMINAL_FAILURE_MESSAGE |
| 551 | + and exception.failure_type == FailureType.transient_error |
| 552 | + for exception in self._non_breaking_exceptions |
| 553 | + ) |
| 554 | + else FailureType.system_error |
| 555 | + ) |
539 | 556 | raise AirbyteTracedException( |
540 | | - message="One or more async jobs failed after exhausting all retry attempts.", |
| 557 | + message=_ASYNC_JOB_FINAL_FAILURE_MESSAGE, |
541 | 558 | internal_message="\n".join( |
542 | 559 | [ |
543 | 560 | filter_secrets(exception.__repr__()) |
544 | 561 | for exception in self._non_breaking_exceptions |
545 | 562 | ] |
546 | 563 | ), |
547 | | - failure_type=FailureType.system_error, |
| 564 | + failure_type=failure_type, |
548 | 565 | ) |
549 | 566 |
|
550 | 567 | def _handle_non_breaking_error(self, exception: Exception) -> None: |
|
0 commit comments