Skip to content

[Bug] Fix batch finalization for existing temp uploads - #3

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-f01d
Draft

[Bug] Fix batch finalization for existing temp uploads#3
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-f01d

Conversation

@cursor

@cursor cursor Bot commented May 2, 2026

Copy link
Copy Markdown

Pull Request Description

Fixes a batch data-loss bug where jobs that already had multipart temp output IDs skipped finalize_job_output_data() in the scheduler execute_job() path. Those jobs could be marked finalized without completing multipart uploads or assembling final output/error files.

Bug and impact:

  • Worker-loaded / resumed jobs can enter execution with temp_output_file_id and temp_error_file_id already set.
  • execute_job() used that as a reason to skip both preparation and final aggregation.
  • When such a job reached FINALIZING, it could be marked FINALIZED while final output objects remained incomplete/missing, causing broken downloads and lost batch results.

Root cause:

  • A single has_temp_files guard was used for two different lifecycle steps: skip output preparation, and skip output finalization.

Fix:

  • Keep skipping preparation when temp file IDs already exist.
  • Always run finalize_job_output_data() when a job reaches FINALIZING.
  • Add a regression test covering an IN_PROGRESS job with existing temp IDs to ensure preparation is not rerun but finalization is invoked before marking done.

Validation performed:

  • PYTHONPATH=/workspace/python/aibrix python3 -m pytest tests/batch/test_driver.py::test_execute_job_finalizes_job_with_existing_temp_files tests/batch/test_driver.py::test_batch_driver_resuming
  • PYTHONPATH=/workspace/python/aibrix python3 -m pytest tests/batch/test_driver.py

Related Issues

Resolves: #

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

Open in Web View Automation 

Co-authored-by: Varun Gupta <varungup90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant