Skip to content

Retry transient StorageException in GcsUtilV2.getBlobs and PackageUtil.alreadyStaged - #41773

Draft
damccorm wants to merge 2 commits into
masterfrom
fix/gcsutilv2-batch-submit-retry-46224436195
Draft

damccorm wants to merge 2 commits into
masterfrom
fix/gcsutilv2-batch-submit-retry-46224436195

Conversation

@damccorm

Copy link
Copy Markdown
Contributor

Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:

  • The PR is an appropriate fix for the issue (e.g. we're not changing a test to avoid a bug)
  • The PR is a simple fix to the issue (e.g. we're not adding infra when we could just modify a test)
  • The PR is not covering for other problems (e.g. if we're bumping timeouts, it is not because we're covering for a performance problem)

Full details of the methodology of generation and review can be found here - https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing

If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)

Summary

Fixes unretried transient GCS read timeouts during Java Dataflow job staging that caused 3 failures across 3 workflows in 7 days (runs https://github.com/apache/beam/actions/runs/45936241381, https://github.com/apache/beam/actions/runs/45935052823, and https://github.com/apache/beam/actions/runs/46224436195).

Production Impact

  • Affected workloads: Java pipelines using GcsUtilV2 (including Cloud Dataflow job submission staging via PackageUtil and FileSystems.matchSingleFileSpec).
  • Symptom: A single transient SocketTimeoutException: Read timed out inside StorageBatch.submit() fails job submission immediately with an unchecked StorageException instead of retrying.
  • Resolution: Single-path getBlobs() lookups bypass unretried multipart batch submission and use getBlob() directly (which applies the GCS client's retry strategy), multi-path batch.submit() falls back to individual getBlob() calls on retryable StorageException and translates non-retryable errors via translateStorageException(), and PackageUtil.tryStagePackageWithRetry() executes alreadyStaged() inside its existing try / catch (IOException) retry loop.

Changes

  • GcsUtilV2.java: Add getBlobResult() reusing getBlob(), bypass StorageBatch when pathPartition.size() == 1, and wrap batch.submit() to fall back on retryable StorageException or translate non-retryable StorageException to IOException.
  • PackageUtil.java: Move alreadyStaged(attributes) inside tryStagePackageWithRetry()'s try / catch (IOException) loop.
  • GcsUtilV2Test.java & PackageUtilTest.java: Add unit tests covering single-path bypass, retryable/non-retryable batch.submit() failures, and transient IOException retries in alreadyStaged().

Verification

  • Triggered beam_PostCommit_Java_DataflowV2.yml workflow run on branch: 46451544121

@damccorm damccorm added the test-failure-cleanup Automated test health and flake cleanup PRs label Nov 30, 2026
@damccorm

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

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.

📋 Review Summary

This PR effectively resolves transient GCS read timeouts during Java Dataflow job staging by bypassing StorageBatch.submit() for single-path lookups, falling back to individual retried getBlob() calls when batch.submit() fails with a retryable StorageException, and moving PackageUtil.alreadyStaged() inside the existing retry loop. The implementation is clean, consistent with GcsUtilV1 behavior, and well-covered by unit tests.

🔍 General Feedback

  • Bypassing StorageBatch when pathPartition.size() == 1 in GcsUtilV2.getBlobs() nicely mirrors GcsUtilV1.getObjects() and ensures single-file metadata lookups leverage the client's configured StorageRetryStrategy.
  • Moving alreadyStaged() inside the try / catch (IOException) block in PackageUtil.tryStagePackageWithRetry() ensures transient errors during pre-upload existence checks are retried with backoff.
  • You may want to consider applying the same batch.submit() StorageException handling and single-item bypass to GcsUtilV2.remove() in a follow-up, as it uses the same StorageBatch pattern.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@damccorm

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

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.

📋 Review Summary

This PR resolves transient GCS read timeout failures during Dataflow package staging and GcsUtilV2.getBlobs lookups by bypassing unretried multipart StorageBatch.submit() calls for single-path partitions, falling back to retried individual getBlob() calls when batch.submit() fails with a retryable StorageException, and moving PackageUtil.alreadyStaged() inside the retry loop.

🔍 General Feedback

  • The changes in GcsUtilV2 and PackageUtil are clean, well-scoped, and properly covered by unit tests.
  • As a follow-up consideration, GcsUtilV2.remove() (around line 655) uses the same StorageBatch.submit() pattern and could benefit from the same single-path bypass and StorageException handling on batch.submit().

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@damccorm damccorm added the ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review label Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.12%. Comparing base (3c2b7a7) to head (f76020f).
⚠️ Report is 120 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #41773   +/-   ##
=========================================
  Coverage     58.12%   58.12%           
  Complexity     2843     2843           
=========================================
  Files          1211     1211           
  Lines        173473   173473           
  Branches       2329     2329           
=========================================
  Hits         100824   100824           
  Misses        69940    69940           
  Partials       2709     2709           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@damccorm

damccorm commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing per updated test-health policy: PostCommit Java Nexmark Dataflow V2 has only 1 master failure(s) in the past 7 days (minimum required is >= 3 failures in a 7-day window). Keeping the branch so this PR can be reopened if PostCommit Java Nexmark Dataflow V2 reaches >= 3 failures in 7 days.

@damccorm damccorm closed this Dec 3, 2026
@damccorm

damccorm commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Reopening under the updated per-issue >= 3 failures in 7 days rule: this StorageException staging failure occurred 3 times in the past 7 days (runs 45935052823, 46224436195, and 46573848386).

@damccorm damccorm reopened this Dec 3, 2026
@damccorm damccorm added ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review and removed ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review labels Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core dataflow extensions gcp java ready-for-human Draft PR with all checks passing and all review comments resolved, ready for human review runners size/m M: 50-249 lines changed test-failure-cleanup Automated test health and flake cleanup PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant