Skip to content

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

Closed
Baz (bazarnov) wants to merge 2 commits intomainfrom
baz/cdk/fix-job-timeout-retry-regression-after-pr-429
Closed

fix: (CDK) (AsyncRetriever) - fix the regression. The TIMEOUT Job Status should Retry on server status.#431
Baz (bazarnov) wants to merge 2 commits intomainfrom
baz/cdk/fix-job-timeout-retry-regression-after-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:

There is a need to introduce the FORCED_TIME_OUT Job status, so we can distinguish between the Server Timeout status of the Job and the status that should be treated as a dead end because of the pooling_job_timeout limitation. This helps us to prevent inf loops when the status_mapping provided incorrectly, such as:

status_mapping:
    failed:
      - failed
    running:
      - pending
      - ready # this should be under the `completed` type.
    timeout:
      - timeout
    completed:
      - dont_care_about_this_status # this is dummy status, doesn't exist.

Summary by CodeRabbit

  • New Features

    • Enhanced job management by introducing a distinct "Forced Timeout" state, providing clearer differentiation for timeout conditions.
  • Tests

    • Added test scenarios to validate both standard and forced timeout behaviors, ensuring proper error handling and job management adjustments.
    • Updated existing test to reflect the new "Forced Timeout" status for improved accuracy in testing job status behavior.

@bazarnov Baz (bazarnov) self-assigned this Mar 19, 2025
Copilot AI review requested due to automatic review settings March 19, 2025 07:58
@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 addresses a regression by distinguishing between TIMED_OUT and FORCED_TIME_OUT job statuses so that server-induced timeouts are retried while system-forced timeouts are handled as terminal errors.

  • Introduces the FORCED_TIME_OUT status and updates its usage in job status evaluation
  • Alters job replacement and removal logic to differentiate how TIMED_OUT versus FORCED_TIME_OUT jobs are processed
  • Updates unit tests to verify the new forced timeout behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
airbyte_cdk/sources/declarative/async_job/job_orchestrator.py Updates job status checks and job replacement/removal logic for forced vs. server timeouts
unit_tests/sources/declarative/async_job/test_job_orchestrator.py Adds test cases to validate forced timeout behavior
airbyte_cdk/sources/declarative/async_job/job.py Modifies job status to return FORCED_TIME_OUT when a timer expires
airbyte_cdk/sources/declarative/async_job/status.py Introduces FORCED_TIME_OUT in the status enumeration and updates related comments
Comments suppressed due to low confidence (2)

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

  • Double-check that including TIMED_OUT jobs (and not FORCED_TIME_OUT) in the jobs-to-replace logic matches the intended behavior; if FORCED_TIME_OUT jobs should not be retried, ensure that this distinction is clearly documented.
failed_status_jobs = (AsyncJobStatus.FAILED, AsyncJobStatus.TIMED_OUT)

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

  • Confirm that changing the status from TIMED_OUT to FORCED_TIME_OUT in job() is fully supported by downstream logic, as this alteration affects how timeouts are handled elsewhere in the system.
if self._timer.has_timed_out(): return AsyncJobStatus.FORCED_TIME_OUT

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2025

📝 Walkthrough

Walkthrough

The changes update the asynchronous job handling by introducing a new timeout status. The AsyncJob class now returns FORCED_TIME_OUT when a timer condition triggers this state. In parallel, the AsyncJobOrchestrator class is modified to recognize and process this status through updated conditions, method renaming, and logic adjustments. The AsyncJobStatus enum is extended with the new value and minor docstring improvements are made. Additionally, two new unit tests verify that both regular and forced timeout conditions raise the expected exceptions and adjust job assignment accordingly.

Changes

File(s) Change Summary
airbyte_cdk/.../async_job/job.py Updated AsyncJob.status method to return FORCED_TIME_OUT instead of TIMED_OUT when the timer indicates it has timed out.
airbyte_cdk/.../async_job/job_orchestrator.py Enhanced job orchestration logic to handle FORCED_TIME_OUT: updated status checks, method renaming (e.g., _remove_completed_or_forced_time_out_jobs), and adjusted timeout handling methods.
airbyte_cdk/.../async_job/status.py Added the FORCED_TIME_OUT enum value to AsyncJobStatus and corrected a docstring typo.
unit_tests/.../async_job/test_job_orchestrator.py Added two unit tests to verify that both timeout scenarios (regular and forced) raise exceptions and handle partition reallocation correctly.
unit_tests/.../async_job/test_job.py Renamed test method to reflect new expected behavior of returning FORCED_TIME_OUT instead of TIMED_OUT.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Orchestrator
  participant Job
  participant Status

  Client->>Orchestrator: Initiate job processing
  Orchestrator->>Job: Call status()
  Job-->>Orchestrator: Return FORCED_TIME_OUT
  Orchestrator->>Orchestrator: Process forced timeout (invoke special handling logic)
  Orchestrator->>Client: Raise AirbyteTracedException
Loading

Possibly related PRs

Suggested reviewers

  • maxi297
  • lmossman

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.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
unit_tests/sources/declarative/async_job/test_job.py (2)

22-25: Method rename and assertion update looks appropriate for the new status type.

I see you've renamed the test method and updated the assertion to check for FORCED_TIME_OUT instead of TIMED_OUT. This aligns perfectly with the implementation changes in AsyncJob.status() and the new enum value in AsyncJobStatus. The test now accurately verifies that when a timer times out, we get the more specific FORCED_TIME_OUT status.

One thought - would it make sense to add an additional test for the AsyncJobOrchestrator class to verify it correctly handles this new status too? The orchestrator code was also updated to include a specific case for FORCED_TIME_OUT. Just a suggestion to increase test coverage, wdyt?


27-32: Placeholder test has helpful documentation but no implementation.

I noticed this test is documented but only contains a pass statement. The comment explains that this test will become important for future metrics/stats functionality. Would it make sense to either:

  1. Implement a basic version now to ensure the timer-stopping behavior works as expected, or
  2. Add a TODO comment with an issue reference to track when this should be implemented?

Having an empty test might be confusing for other developers wondering if the functionality is tested elsewhere.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0a6b0f2 and 425c500.

📒 Files selected for processing (2)
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py (7 hunks)
  • unit_tests/sources/declarative/async_job/test_job.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/async_job/job_orchestrator.py
🧰 Additional context used
🧬 Code Definitions (1)
unit_tests/sources/declarative/async_job/test_job.py (3)
airbyte_cdk/sources/declarative/async_job/job.py (2) (2)
  • AsyncJob (13-52)
  • status (35-38)
airbyte_cdk/sources/declarative/async_job/job_orchestrator.py (1) (1)
  • status (87-102)
airbyte_cdk/sources/declarative/async_job/status.py (1) (1)
  • AsyncJobStatus (9-26)
⏰ 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: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Analyze (python)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)

@bazarnov
Copy link
Copy Markdown
Contributor Author

Closed, in favor of: #432

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.

2 participants