Skip to content

Conversation

@viragtripathi
Copy link

Add support for CockroachDB v25.4.0+ using the official cockroach-go/v2 library for automatic transaction retry.

  • Add CockroachDB source with ExecuteTxWithRetry using crdbpgx.ExecuteTx
  • Implement 4 tools: execute-sql, sql, list-tables, list-schemas
  • Use UUID primary keys (CockroachDB best practice)
  • Add unit tests for source and all tools
  • Add integration tests with retry verification
  • Update Cloud Build configuration for CI

Fixes #2005

Description

Should include a concise description of the changes (bug or feature), it's
impact, along with a summary of the solution

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@viragtripathi viragtripathi requested a review from a team as a code owner November 20, 2025 19:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @viragtripathi, 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 expands the toolbox's capabilities by introducing a robust integration with CockroachDB. It provides a reliable mechanism for interacting with CockroachDB instances, including automatic transaction retries for enhanced fault tolerance. Developers can now leverage a set of specialized tools to execute SQL, query schema and table metadata, streamlining database operations within the ecosystem. The changes also ensure that the new integration adheres to CockroachDB best practices and is thoroughly tested through both unit and integration tests, with updated CI to reflect these additions.

Highlights

  • CockroachDB Integration: Full support for CockroachDB v25.4.0+ has been added, leveraging the official cockroach-go/v2 library.
  • Automatic Transaction Retry: The integration includes ExecuteTxWithRetry using crdbpgx.ExecuteTx to handle transient errors and ensure transaction consistency.
  • New Database Tools: Four new tools are introduced for CockroachDB: execute-sql (for general SQL execution), sql (for parameterized SQL queries), list-tables (to retrieve table metadata), and list-schemas (to list database schemas).
  • UUID Primary Keys: The implementation promotes CockroachDB best practices by utilizing UUID primary keys.
  • Comprehensive Testing: New unit tests cover the CockroachDB source and all new tools, alongside integration tests that specifically verify the retry mechanism.
  • CI/CD Updates: The Cloud Build configuration has been updated to include the new CockroachDB integration tests in the continuous integration pipeline.
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
Contributor

@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 introduces CockroachDB integration, including a new source and four tools. The implementation correctly uses the cockroach-go/v2 library for its core retry logic in the source. However, a critical oversight is that none of the new tools actually use this retry mechanism, instead interacting with the connection pool directly. This undermines a key benefit of the integration. Additionally, there's a bug in how connection string query parameters are constructed, which could fail with special characters. I've also noted some inconsistencies in result formatting and error handling compared to existing tools. The integration and unit tests are a good start but could be expanded to cover these tools more directly.

@duwenxin99 duwenxin99 assigned duwenxin99 and unassigned Yuan325 Nov 21, 2025
Add complete CockroachDB v25.4.0+ integration using official cockroach-go/v2
library for automatic transaction retry.

- Add source with Query() for read operations
- Implement 4 tools: execute-sql, sql, list-tables, list-schemas
- Use UUID primary keys (CockroachDB best practice)
- Add comprehensive unit and integration tests (18 tests)
- Add complete documentation for source and all tools
- Update Cloud Build configuration for CI

Tested on CockroachDB v25.4.0 multi-region cluster.

Fixes googleapis#2005
@viragtripathi viragtripathi force-pushed the feat/cockroachdb-integration branch from c90de3d to ea146d7 Compare November 22, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CockroachDB integration support

3 participants