Skip to content

impl(bigtable): improve query execution refresh and retry#15788

Merged
scotthart merged 2 commits intogoogleapis:mainfrom
scotthart:bigtable_query_retry_and_refresh
Nov 20, 2025
Merged

impl(bigtable): improve query execution refresh and retry#15788
scotthart merged 2 commits intogoogleapis:mainfrom
scotthart:bigtable_query_retry_and_refresh

Conversation

@scotthart
Copy link
Copy Markdown
Member

  • Introduces separate retry traits, policy, and option, QueryPlanRefreshFunctionRetry, for query plan refresh attempts which have a broader definition of transient errors.
  • Renames QueryPlanRefreshRetry to ExecuteQueryPlanRefreshRetry to be more precise and differentiate it from QueryPlanRefreshFunctionRetry.
  • Adds a wrapper class, QueryPlanRefreshingPartialResultSource, that handles the query plan refresh logic and recreating the PartialResultSource if necessary depending on when in the stream creation/processing the query plan refresh is indicated.
  • Updated PartialResultSetSouce::resume_token_ documentation to match Bigtable implementation.
  • Enables all the Bigtable ExecuteQuery conformance tests that we currently plan to support.

@scotthart scotthart requested a review from a team November 20, 2025 17:25
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Nov 20, 2025
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @scotthart, 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 robustness and clarity of Bigtable's query execution by enhancing its query plan refresh and retry mechanisms. It introduces a more granular approach to handling transient errors during query plan refreshes and centralizes the refresh logic within a dedicated class. These changes lead to a more resilient system, better organized code, and expanded test coverage for Bigtable's ExecuteQuery functionality.

Highlights

  • Refined Query Plan Refresh Retry Policies: Introduced a new, distinct retry trait, policy, and option (QueryPlanRefreshFunctionRetry) specifically for internal query plan refresh attempts, allowing for a broader definition of transient errors (including kInternal). The existing query plan refresh retry mechanism has been renamed to ExecuteQueryPlanRefreshRetry for clarity, differentiating between the overall query execution retry and the internal refresh function's retry.
  • Centralized Query Plan Refresh Logic: A new wrapper class, QueryPlanRefreshingPartialResultSource, has been added to encapsulate and manage the complex logic for query plan refreshing and the recreation of PartialResultSource instances. This streamlines the ExecuteQuery implementation by abstracting the retry loop and refresh handling.
  • Enhanced Conformance Test Coverage: More Bigtable ExecuteQuery conformance tests have been enabled, indicating improved stability and correctness of the query execution and refresh mechanisms. This expands the scope of supported scenarios and ensures better adherence to Bigtable's expected behavior.
  • Updated resume_token_ Documentation: The documentation for PartialResultSetSource::resume_token_ has been updated to accurately reflect the Bigtable implementation details, providing clearer guidance on its purpose and behavior during query resumption and retries.
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 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 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

  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.

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 significantly improves the query execution and retry logic. The introduction of the QueryPlanRefreshingPartialResultSource class is a great refactoring that encapsulates the complex logic for handling query plan refreshes, making the ExecuteQuery method much cleaner. The renaming of various policies and traits for clarity, and the addition of a separate retry policy for the query plan refresh function, are also welcome improvements. The changes look solid and improve the robustness and maintainability of the code. I have a couple of minor suggestions for improving code style and consistency.

Comment thread google/cloud/bigtable/internal/data_connection_impl.cc Outdated
Comment thread google/cloud/bigtable/retry_policy.h
Comment thread google/cloud/bigtable/internal/data_connection_impl.cc Outdated
}
last_status = source.status();

if (IsStatusIndicatingInternalError(source.status())) {
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.

I suspected there was a better place for this check. How is it being handled now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's part of the different Retry traits defined in retry_traits.h. Unfortunately, refreshing query plans as part of streaming the query results requires a total of 3 different retry traits depending on what operation is occurring.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 74.82517% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.94%. Comparing base (45fe5af) to head (a3347de).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ogle/cloud/bigtable/tests/data_integration_test.cc 0.00% 18 Missing ⚠️
google/cloud/bigtable/internal/retry_traits.h 0.00% 7 Missing ⚠️
...le/cloud/bigtable/internal/data_connection_impl.cc 92.40% 6 Missing ⚠️
google/cloud/bigtable/retry_policy.h 76.92% 3 Missing ⚠️
...oud/bigtable/internal/partial_result_set_source.cc 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15788      +/-   ##
==========================================
- Coverage   92.94%   92.94%   -0.01%     
==========================================
  Files        2454     2454              
  Lines      226878   226946      +68     
==========================================
+ Hits       210879   210933      +54     
- Misses      15999    16013      +14     

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

@scotthart scotthart enabled auto-merge (squash) November 20, 2025 19:43
@scotthart scotthart merged commit 8e3250e into googleapis:main Nov 20, 2025
68 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants