Skip to content

Isolate Cloud AI local-file offloads from default executor - #1735

Merged
groupthinking merged 4 commits into
mainfrom
copilot/fix-shared-default-executor-leak
Sep 12, 2026
Merged

groupthinking merged 4 commits into
mainfrom
copilot/fix-shared-default-executor-leak

Conversation

Copilot AI commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Canonical issue

Linked by system.

Outcome

Prevents stalled local file reads (e.g., remote-backed mounts) in Cloud AI image paths from consuming default asyncio executor capacity shared by unrelated subsystems.

  • Dedicated blocking I/O lane: added a Cloud AI–scoped thread pool + run_blocking(...) helper.
  • Targeted migration (AC1): moved local _read_file_bytes offloads in AWS Rekognition, Azure Vision, and Google Cloud providers to the dedicated pool.
  • Saturation observability (AC3): emits structured warning when active+queued work reaches pool capacity.
  • Isolation proof (AC2): regression test saturates the Cloud AI I/O pool and verifies unrelated default asyncio.to_thread(...) work still completes.
# before
await asyncio.to_thread(_read_file_bytes, str(safe_path))

# after
await run_blocking(_read_file_bytes, str(safe_path))

Scope

  • Included:
    • New module: integrations/cloud_ai/blocking_io.py (ThreadPoolExecutor + run_blocking)
    • Provider routing updates in:
      • providers/aws_rekognition.py
      • providers/azure_vision.py
      • providers/google_cloud.py
    • Regression/contract tests:
      • tests/unit/test_cloud_ai_blocking_io.py
      • provider routing assertions in each provider test file
  • Explicitly excluded:
    • Repo-wide migration of all to_thread / run_in_executor(None, ...) call sites
    • Behavioral changes to non-local-file provider operations

Risk

  • Risk level: medium
  • Failure mode:
    • Mis-sized Cloud AI pool can increase latency for Cloud AI local-file reads under burst.
    • Invalid CLOUD_AI_IO_MAX_WORKERS value falls back to default with warning.
  • Rollback:
    • Revert provider call sites to asyncio.to_thread(...) and remove blocking_io.py.

Verification

List exact automated and manual checks, tied to the current head SHA.

Head SHA: e551419

  • Focused tests
  • Required CI
  • Review threads resolved

Production evidence

Not applicable: backend concurrency/isolation change with unit-level regression coverage; no UI or deploy-surface delta.

Agent handoff

  • One canonical issue is linked
  • No competing PR implements the same issue
  • Acceptance criteria are satisfied
  • Required checks pass on the current head
  • Human decision is requested only for product, security, irreversible infrastructure, or production approval

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
v0-uvai Ready Ready Preview, v0 Sep 12, 2026 9:35am UTC

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix blocking I/O offloads causing default executor leaks Isolate Cloud AI local-file offloads from default executor Sep 8, 2026
Copilot AI requested a review from groupthinking September 8, 2026 23:53
active,
queued,
_IO_MAX_WORKERS,
)

@vercel vercel Bot Sep 8, 2026

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.

_IO_QUEUED counter permanently leaks by 1 whenever a queued blocking-I/O work item is cancelled (via timeout or task cancellation) before it starts running.

Fix on Vercel

@groupthinking
groupthinking marked this pull request as ready for review September 12, 2026 09:34
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: bf04d445-d71d-4732-ac4e-1e1436c90c5d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@groupthinking
groupthinking merged commit 637f719 into main Sep 12, 2026
1 check was pending
@groupthinking
groupthinking deleted the copilot/fix-shared-default-executor-leak branch September 12, 2026 09:34
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA a8be54f.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Validation

⚠️ PR title should follow conventional commits format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocking I/O offloads share the default executor, so one stalled read can starve the process

2 participants