Skip to content

Conversation

@jac0626
Copy link
Collaborator

@jac0626 jac0626 commented Jan 6, 2026

@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jac0626
To complete the pull request process, please assign longjiquan after the PR has been reviewed.
You can assign the PR to them by writing /assign @longjiquan in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link

Summary of Changes

Hello @jac0626, 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 implements a significant refactoring of how database names (db_name) are handled within the PyMilvus client. The primary goal is to fix a bug that arose when multiple client instances shared a single connection, leading to incorrect database context. By moving db_name management from the connection alias to individual client instances and injecting it into API calls via a decorator, the change ensures robust database isolation and prevents unintended cross-client interactions, improving the stability and predictability of client operations.

Highlights

  • Database Name Handling Refactor: The db_name is no longer part of the connection alias, resolving a bug (issue [Bug]:Connection Reuse Issue with use_database() Causing Database Context Contamination #3175) where multiple clients sharing a connection could interfere with each other's database context. Instead, db_name is now managed per client instance and passed as a parameter with each request.
  • Client-Side Database Context: Each MilvusClient and AsyncMilvusClient instance now stores its own _db_name attribute. A new _inject_db_name decorator automatically injects this instance-specific db_name into the keyword arguments of most API methods, ensuring proper database isolation.
  • Deprecated reset_db_name Method: The reset_db_name method in grpc_handler.py has been deprecated. Users are now advised to use MilvusClient.use_database() (or AsyncMilvusClient.use_database()) which updates the client's internal _db_name attribute without affecting shared connection state.
  • Enhanced Test Coverage: New unit tests have been added in test_milvus_client_db_isolation.py to specifically verify that multiple client instances correctly maintain separate database contexts even when sharing the same underlying connection.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@mergify mergify bot added the dco-passed label Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 85.33835% with 39 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@20c43b4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pymilvus/client/grpc_handler.py 41.02% 23 Missing ⚠️
pymilvus/milvus_client/async_milvus_client.py 91.58% 9 Missing ⚠️
pymilvus/client/interceptor.py 50.00% 3 Missing ⚠️
pymilvus/milvus_client/milvus_client.py 97.14% 3 Missing ⚠️
pymilvus/client/async_grpc_handler.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3176   +/-   ##
=========================================
  Coverage          ?   47.57%           
=========================================
  Files             ?       66           
  Lines             ?    14625           
  Branches          ?        0           
=========================================
  Hits              ?     6958           
  Misses            ?     7667           
  Partials          ?        0           

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

@jac0626 jac0626 changed the title fix:remove db_name from alias, pass db_name as a param [WIP]fix:remove db_name from alias, pass db_name as a param Jan 6, 2026
@mergify mergify bot added the ci-passed label Jan 6, 2026
Copy link

@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 correctly addresses the issue of db_name being part of the connection alias, which caused bugs when multiple clients with different databases shared a connection. The fix involves removing db_name from the connection alias and treating it as a per-client context. This is implemented by storing _db_name in each client instance and injecting it into API calls via a decorator. The changes are well-supported by a new test suite for database isolation.
I've found one issue in async_milvus_client.py where the use_database method is incorrectly defined as async, which could lead to runtime warnings and unexpected behavior. My review includes a suggestion to fix this.

@jac0626 jac0626 force-pushed the fix/resue_connection branch from 0235f3c to f6286ec Compare January 6, 2026 10:54
@jac0626 jac0626 force-pushed the fix/resue_connection branch from f6286ec to 130edb1 Compare January 7, 2026 03:41
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.

2 participants