Skip to content

Resolve race when staging multiple classic templates at the same time#3839

Draft
Abacn wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Abacn:stage-conflict
Draft

Resolve race when staging multiple classic templates at the same time#3839
Abacn wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Abacn:stage-conflict

Conversation

@Abacn
Copy link
Copy Markdown
Contributor

@Abacn Abacn commented May 20, 2026

context: #3833 (comment)

There is a racing condition when multiple classic templates get staged, jars are overwrittened by each other. gcsio correctly handles this race, but unfortunately, it's printing an log triggering a JDK bug.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a race condition occurring when multiple classic templates are staged simultaneously, which previously led to file corruption. By implementing conditional synchronization specifically for classic templates, the change ensures thread safety during the staging process while avoiding unnecessary performance impacts on flex templates.

Highlights

  • Race Condition Resolution: Introduced a synchronized block for classic templates to prevent file overwriting during the staging process.
  • Code Refactoring: Extracted the staging logic into a Callable to allow for conditional synchronization based on the template type.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.21%. Comparing base (74e5f1f) to head (48faf51).
⚠️ Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
.../java/org/apache/beam/it/gcp/TemplateTestBase.java 0.00% 6 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3839      +/-   ##
============================================
+ Coverage     53.06%   54.21%   +1.15%     
- Complexity     6018     6895     +877     
============================================
  Files          1070     1096      +26     
  Lines         64941    67358    +2417     
  Branches       7193     7559     +366     
============================================
+ Hits          34463    36521    +2058     
- Misses        28166    28373     +207     
- Partials       2312     2464     +152     
Components Coverage Δ
spanner-templates 73.35% <ø> (+0.48%) ⬆️
spanner-import-export 68.65% <ø> (ø)
spanner-live-forward-migration 83.02% <ø> (+2.02%) ⬆️
spanner-live-reverse-replication 77.09% <ø> (-0.12%) ⬇️
spanner-bulk-migration 90.97% <ø> (-0.18%) ⬇️
gcs-spanner-dv 85.75% <ø> (-0.08%) ⬇️
Files with missing lines Coverage Δ
.../java/org/apache/beam/it/gcp/TemplateTestBase.java 0.00% <0.00%> (ø)

... and 79 files with indirect coverage changes

🚀 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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies TemplateTestBase.java to refactor the template staging process. It extracts the staging logic into a Callable and introduces conditional synchronization on the stagedTemplates object when processing non-flex templates, likely to ensure thread safety during the staging operation. There were no review comments provided for this pull request, so I have no feedback to provide.

@Abacn Abacn marked this pull request as draft May 21, 2026 02:48
@Abacn
Copy link
Copy Markdown
Contributor Author

Abacn commented May 21, 2026

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.

1 participant