-
Notifications
You must be signed in to change notification settings - Fork 322
fix: updates timeout/retry code to respect hanging server #2408
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @chalmerlowe, 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 significantly improves the stability and predictability of the BigQuery client library by addressing critical issues in error handling and timeout management. It ensures that the retry mechanism can robustly handle various gRPC error formats without crashing and guarantees that data retrieval operations from the BigQuery Storage API will respect specified timeouts, preventing unresponsive client states. Highlights
Using Gemini Code AssistThe 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
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 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 up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 addresses a crash in retry logic and ensures proper timeout propagation. The changes in google/cloud/bigquery/retry.py add robust error inspection to handle unstructured gRPC errors, while the updates in google/cloud/bigquery/table.py and google/cloud/bigquery/_pandas_helpers.py ensure that the user-specified timeout is correctly passed down to the underlying to_arrow and create_read_session calls. A new test case is added to verify the timeout propagation.
| try: | ||
| reason = exc.errors[0]["reason"] | ||
| except (AttributeError, IndexError, TypeError, KeyError): | ||
| # Fallback for when errors attribute is missing, empty, or not a dict | ||
| # or doesn't contain "reason" (e.g. gRPC exceptions). | ||
| return isinstance(exc, _UNSTRUCTURED_RETRYABLE_TYPES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR fixes a crash when handling
_InactiveRpcErrorduring retry logic and ensures propertimeoutpropagation inRowIterator.to_dataframe.Fixes
Retry Logic Crash: Addressed an issue in
google/cloud/bigquery/retry.pywhere_should_retrywould raise aTypeErrorwhen inspecting unstructuredgRPCerrors (like_InactiveRpcError). The fix adds robust error inspection to fallback gracefully whenexc.errorsis not subscriptable.Timeout Propagation: Added the missing
timeoutparameter toRowIterator.to_dataframeingoogle/cloud/bigquery/table.py. This ensures that the user-specifiedtimeoutis correctly passed down to the underlyingto_arrowcall, preventing the client from hanging indefinitely when the Storage API is unresponsive.Changes
Modified
google/cloud/bigquery/retry.py: Updated_should_retryto handleTypeErrorandKeyErrorwhen accessingexc.errors.Modified
google/cloud/bigquery/table.py: UpdatedRowIterator.to_dataframesignature and implementation to accept and pass thetimeoutparameter.The first half of this work was completed in PR #2354