Skip to content

fix: route insert-runner thread safety through a client capability - #849

Open
serhiizghama wants to merge 3 commits into
zilliztech:mainfrom
serhiizghama:fix/rate-runner-thread-safe-capability
Open

fix: route insert-runner thread safety through a client capability#849
serhiizghama wants to merge 3 commits into
zilliztech:mainfrom
serhiizghama:fix/rate-runner-thread-safe-capability

Conversation

@serhiizghama

Copy link
Copy Markdown

Fixes #810. The fixed-rate insert runner decided per-thread client handling by checking db.name against a hardcoded list (PgVector, Doris, SeekDB, VolcMySQL), so clients that declare thread_safe = False but aren't on that list — OceanBase, VectorChord, Adbpg, LanceDB — fell through to the default path and shared one non-thread-safe connection across insert workers. OceanBase was never in the list at all.

I moved the decision onto the existing thread_safe capability. The runner now branches on db.thread_safe and asks the client for a per-thread copy via a new VectorDB.copy_for_thread(). The default deep-copies the instance, which already works for the psycopg-family clients and for LanceDB (it has a custom __deepcopy__); the mysql.connector-backed clients override it to shallow-copy and drop their open socket so init() reconnects inside the worker. Behavior for the databases that were already special-cased is unchanged — the capability just also covers the ones the name list missed, and adding a new non-thread-safe client no longer means remembering to edit the runner.

Added a unit test that drives send_insert_task with a fake client and checks that thread-safe clients insert through the shared object while non-thread-safe ones go through a copy plus init().

Replace the db.name branching in RatedMultiThreadingInsertRunner with a
VectorDB.copy_for_thread() hook driven by the existing thread_safe flag, so
non-thread-safe clients get a per-thread copy without the runner hardcoding
which databases those are.
The mysql.connector-backed clients (SeekDB, VolcMySQL, OceanBase) can't be
deep-copied while holding an open socket, and Doris needs its client/table
cleared; each now overrides copy_for_thread accordingly. OceanBase was
previously missing from the runner's name list entirely, so its fixed-rate
insert workers shared one connection.
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: serhiizghama
To complete the pull request process, please assign xuanyang-cn after the PR has been reviewed.
You can assign the PR to them by writing /assign @xuanyang-cn 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

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.

Fixed-rate insert runner can share non-thread-safe DB clients

2 participants