Skip to content

fix: (CDK) (AsyncRetriever) - fix the regression. The TIMEOUT Job Status should Retry on server status#432

Merged
Baz (bazarnov) merged 3 commits intomainfrom
baz/cdk/fix-job-timeout-retry-regression-after-the-pr-429
Mar 19, 2025
Merged

fix: (CDK) (AsyncRetriever) - fix the regression. The TIMEOUT Job Status should Retry on server status#432
Baz (bazarnov) merged 3 commits intomainfrom
baz/cdk/fix-job-timeout-retry-regression-after-the-pr-429

Conversation

@bazarnov
Copy link
Copy Markdown
Contributor

@bazarnov Baz (bazarnov) commented Mar 19, 2025

What

Given this dialog: https://airbytehq-team.slack.com/archives/C07JMAAE620/p1742346710533189?thread_ts=1742236041.905529&cid=C07JMAAE620

Related to:

Summary by CodeRabbit

  • New Features
    • Introduced configurable retry limits for asynchronous job processing, offering more flexible handling of job timeouts.
  • Bug Fixes
    • Enhanced error handling during timeout scenarios to improve job tracking behavior.
  • Refactor
    • Streamlined job status and partition management to enhance stability and reduce errors during timeout scenarios.
  • Tests
    • Updated test cases to validate the improved retry logic and timeout behavior for more reliable operations.

@bazarnov Baz (bazarnov) self-assigned this Mar 19, 2025
Copilot AI review requested due to automatic review settings March 19, 2025 15:32
@github-actions github-actions bot added bug Something isn't working security labels Mar 19, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regression with the TIMEOUT job status by enabling retries on timed‐out jobs and by making the retry behavior configurable with the job_max_retry parameter.

  • Added a TODO comment in the async job to indicate future improvements in handling TIMEOUT responses.
  • Updated AsyncPartition and AsyncJobOrchestrator to accept a configurable job_max_retry parameter and adjusted the logic to include TIMEOUT in the retry flow.
  • Modified the Connector Builder path to set job_max_retry appropriately.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
airbyte_cdk/sources/declarative/async_job/job.py Added a TODO comment regarding handling of TIMEOUT status; returns TIMED_OUT when timer expires.
airbyte_cdk/sources/declarative/async_job/job_orchestrator.py Updated constructor and partition/retry handling to use job_max_retry; adjusted cleanup and abort logic for timed-out jobs.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Configured job_max_retry for the Connector Builder use-case to enforce a single retry when active.
Comments suppressed due to low confidence (4)

airbyte_cdk/sources/declarative/async_job/job.py:37

  • [nitpick] Consider enhancing this TODO comment with additional context or a reference to the intended API behavior to guide future improvements.
# TODO: we should account the fact that,

airbyte_cdk/sources/declarative/async_job/job_orchestrator.py:388

  • Ensure that not freeing the job allocation for timed-out jobs is the intended design to allow for their retry; consider adding a clarifying comment.
self._abort_job(job, free_job_allocation=False)

airbyte_cdk/sources/declarative/async_job/job_orchestrator.py:406

  • [nitpick] Confirm that omitting TIMED_OUT jobs from removal here aligns with the desired retry behavior for timed-out jobs.
if job.status() == AsyncJobStatus.COMPLETED:

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:3080

  • [nitpick] Verify that setting job_max_retry to 1 for Connector Builder use-cases is the intended behavior and that it is adequately covered by tests.
job_max_retry=1 if self._emit_connector_builder_messages else None,

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2025

📝 Walkthrough

Walkthrough

This pull request introduces modifications to the handling of asynchronous jobs. In the AsyncJob class, comments have been added to the status method to indicate that certain APIs may return a timeout status, prompting a reconsideration of the current retry logic. Additionally, the job_orchestrator.py and model_to_component_factory.py files have been updated to include a configurable job_max_retry parameter, enhancing the flexibility of retry attempts without altering the overall execution flow.

Changes

File(s) Change Summary
airbyte_cdk/.../async_job/job.py Added inline comments in the status method of AsyncJob to highlight that API responses indicating timeouts might not always necessitate a retry (the logic remains unchanged).
airbyte_cdk/.../async_job/job_orchestrator.py,
airbyte_cdk/.../parsers/model_to_component_factory.py
Introduced a configurable job_max_retry parameter by replacing the _MAX_NUMBER_OF_ATTEMPTS constant. Updated method signatures and revised internal logic for retry handling, timeout inclusion, and job replacement processes.

Sequence Diagram(s)

sequenceDiagram
    participant Orchestrator as AsyncJobOrchestrator
    participant Partition as AsyncPartition
    participant Job as AsyncJob
    participant Repo as AsyncJobRepository

    Orchestrator->>Partition: Create partition (pass job_max_retry)
    Partition->>Job: Start job execution
    Note over Job,Partition: Job execution monitored for timeout or failure
    alt Job experiences timeout
        Partition->>Partition: Check has_reached_max_attempt(job_max_retry)
        alt Retry limit not reached
            Partition->>Orchestrator: Request job retry/replacement
        else Retry limit reached
            Partition->>Orchestrator: Abort job without retry
        end
    end
Loading

Possibly related PRs

Suggested reviewers

  • brianjlai
  • maxi297
  • pnilan

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 483db58 and 5c67a42.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Analyze (python)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming that this fixes the tests in source-salesforce. Thanks a lot Baz (@bazarnov) ❤️ !

Comment thread airbyte_cdk/sources/declarative/async_job/job_orchestrator.py
@bazarnov Baz (bazarnov) merged commit 2b1f325 into main Mar 19, 2025
26 checks passed
@bazarnov Baz (bazarnov) deleted the baz/cdk/fix-job-timeout-retry-regression-after-the-pr-429 branch March 19, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants