Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(storage): gRPC misuse causing crashes due to concurrent writes from Flush() and Write()#15802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
v-pratap wants to merge1 commit intogoogleapis:main
base:main
Choose a base branch
Loading
fromv-pratap:fastbyte-bug-5

Conversation

@v-pratap
Copy link
Contributor

@v-pratapv-pratap commentedNov 27, 2025
edited
Loading

A gRPC misuse issue can lead to crashes when using the async writer. The issue occurs due to a race condition between user code and the SDK's internal handling of Flush() operations.

Here's a breakdown of the problem:

When a Flush() is issued, the buffer is cleaned up asynchronously via OnQuery() after the flush future is marked complete. OnQuery() can then call WriteLoop(), which issues a write. However, user code can also call Write() after the Flush() future is complete, which can also call WriteLoop(). This can result in two concurrent writes to the same gRPC stream, which is against the gRPC API contract and can cause a crash.

@v-pratapv-pratap requested review froma team ascode ownersNovember 27, 2025 06:37
@product-auto-labelproduct-auto-labelbot added the api: storageIssues related to the Cloud Storage API. labelNov 27, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello@v-pratap, 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 resolves a critical race condition within the gRPC async writer that could lead to application crashes. The issue arose fromFlush() andWrite() operations potentially initiating concurrent writes to the same gRPC stream, violating the gRPC API contract. The solution involves introducing and carefully managing awriting_ flag to serialize write operations, ensuring only one write is active at a time. This prevents the problematic concurrent access and stabilizes the async writer. A new test case has been added to thoroughly validate this fix.

Highlights

  • Race Condition Fix: Addressed a critical gRPC misuse issue that caused crashes due to a race condition betweenFlush() andWrite() operations, leading to concurrent writes on the same gRPC stream.
  • Concurrent Write Prevention: Implemented awriting_ flag to ensure that only one write operation (either fromFlush() orWrite()) is active at any given time, thereby preventing concurrent gRPC writes.
  • Logic Reordering inOnQuery: Reordered the execution flow within theOnQuery callback to ensure thatSetFlushed is called after theOnQuery processing, preventing potential issues with object lifetime management.
  • New Test Case: Introduced a new test case,NoConcurrentWritesWhenFlushAndWriteRace, to specifically validate the fix and ensure that concurrentFlush() andWrite() calls no longer result in concurrent gRPC writes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on ourdocumentation 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.

FeatureCommandDescription
Code Review/gemini reviewPerforms a code review for the current pull request in its current state.
Pull Request Summary/gemini summaryProvides a summary of the current pull request in its current state.
Comment@gemini-code-assistResponds in comments when explicitly tagged, both in pull request comments and review comments.
Help/gemini helpDisplays a list of available commands.

Customization

To customize 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 foundhere.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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 uphere.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with theGemini Code Assist IDE Extension.

Footnotes

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

Copy link

@gemini-code-assistgemini-code-assistbot 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 effectively resolves a critical race condition that could cause crashes due to concurrent writes on a gRPC stream. The solution, which involves introducing awriting_ flag for serialization and adjusting the order of asynchronous operations, is sound and well-implemented. The new test case,NoConcurrentWritesWhenFlushAndWriteRace, is particularly valuable as it specifically targets the race condition and confirms the fix. The changes significantly enhance the thread safety and reliability of the async writer. I have one minor style suggestion.

{
std::unique_lock<std::mutex>lk(mu_);
was_finalizing = finalizing_;
was_finalizing = finalizing_;

Choose a reason for hiding this comment

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

medium

This line contains trailing whitespace. The repository's style guide indicates it follows the Google C++ Style Guide, which advises against trailing whitespace for code cleanliness.1

was_finalizing=finalizing_;

Style Guide References

Footnotes

@codecov
Copy link

codecovbot commentedNov 27, 2025

Codecov Report

❌ Patch coverage is89.47368% with8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.93%. Comparing base (c03c99b) to head (6b5569a).

Files with missing linesPatch %Lines
...e/internal/async/writer_connection_resumed_test.cc87.30%8 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main   #15802      +/-   ##==========================================- Coverage   92.94%   92.93%   -0.01%==========================================  Files        2457     2457                Lines      227128   227190      +62     ==========================================+ Hits       211099   211148      +49- Misses      16029    16042      +13

☔ View full report in Codecov by Sentry.
📢 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.

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

Reviewers

1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

api: storageIssues related to the Cloud Storage API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@v-pratap

[8]ページ先頭

©2009-2025 Movatter.jp