Skip to content

fix(pgvector): normalize index_type to lowercase in _create_index to …#760

Merged
foxspy merged 3 commits intozilliztech:mainfrom
shaohuasong-fang:patch-1
Apr 20, 2026
Merged

fix(pgvector): normalize index_type to lowercase in _create_index to …#760
foxspy merged 3 commits intozilliztech:mainfrom
shaohuasong-fang:patch-1

Conversation

@shaohuasong-fang
Copy link
Copy Markdown
Contributor

…match PostgreSQL access method names

PostgreSQL pgvector extension registers index access methods in lowercase (e.g. "hnsw", "ivfflat"), but the frontend passes IndexType.HNSW.value which is uppercase "HNSW", causing "access method HNSW does not exist" error.

…match PostgreSQL access method names

PostgreSQL pgvector extension registers index access methods in lowercase
(e.g. "hnsw", "ivfflat"), but the frontend passes IndexType.HNSW.value
which is uppercase "HNSW", causing "access method HNSW does not exist" error.
@foxspy
Copy link
Copy Markdown
Collaborator

foxspy commented Apr 17, 2026

/assign @jamesgao-jpg

@shaohuasong-fang
Copy link
Copy Markdown
Contributor Author

/assign @XuanYang-cn

Replaced index_param['index_type'] with index_type_lower for consistency.
else sql.Identifier("embedding")
),
index_type=sql.Identifier(index_param["index_type"]),
[FIX] Use lowercase index_type_lower instead of original index_param["index_type"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SyntaxError [FIX]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I should add a # before [FIX] and have submitted the latest minor version.
lastest minor version url:1a2c0c1

@foxspy
Copy link
Copy Markdown
Collaborator

foxspy commented Apr 17, 2026

@shaohuasong-fang Mind running this locally first to make sure it works? Thanks!

@shaohuasong-fang
Copy link
Copy Markdown
Contributor Author

I have submitted a minor version,url :1a2c0c1

@shaohuasong-fang
Copy link
Copy Markdown
Contributor Author

I forgot copy sign "#" when i copied that line,sorry。

@shaohuasong-fang
Copy link
Copy Markdown
Contributor Author

lastest minor version is 1a2c0c1

I have added the # before [FIX]
Copy link
Copy Markdown
Contributor Author

@shaohuasong-fang shaohuasong-fang left a comment

Choose a reason for hiding this comment

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

I have added the comment sign '#' before [FIX],please review lastest code.

else sql.Identifier("embedding")
),
index_type=sql.Identifier(index_param["index_type"]),
[FIX] Use lowercase index_type_lower instead of original index_param["index_type"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I should add a # before [FIX] and have submitted the latest minor version.
lastest minor version url:1a2c0c1

@shaohuasong-fang
Copy link
Copy Markdown
Contributor Author

lastest version:a9d32b8
I confirm that the modifications have been completed. Please review.

Copy link
Copy Markdown
Collaborator

@foxspy foxspy left a comment

Choose a reason for hiding this comment

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

/lgtm

@sre-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: foxspy, shaohuasong-fang
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

@foxspy foxspy merged commit 5a9173e into zilliztech:main Apr 20, 2026
@XuanYang-cn
Copy link
Copy Markdown
Collaborator

I believe this could fixed the #759

XuanYang-cn added a commit to XuanYang-cn/VectorDBBench that referenced this pull request Apr 21, 2026
For non-thread-safe DBs (e.g. PgVector), ConcurrentInsertRunner clamps
max_workers to 1, so there is always exactly one worker thread. There is
no need to deepcopy self.db per thread — the single worker can use
self.db directly via the connection already opened by task()'s
`with self.db.init():`.

The original code called deepcopy(self.db) inside _get_thread_db() after
task() had already opened a live psycopg C-extension Connection on
self.db. C-extension objects cannot be deep-copied, causing:
  TypeError: no default __reduce__ due to non-trivial __cinit__

Fix: remove the deepcopy branch entirely. All workers (thread-safe or
not) now use self.db directly; thread-safety is guaranteed for
non-thread-safe DBs by the max_workers=1 clamp.

Also clean up stale comments in pgvector.py left over from zilliztech#760/zilliztech#763.

Adds tests/test_pgvector.py with:
- unit test that reproduces the bug (fails on original, passes on fix)
- e2e regression test via ConcurrentInsertRunner + OpenAI 50K dataset

See also: zilliztech#756

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
XuanYang-cn added a commit that referenced this pull request Apr 21, 2026
For non-thread-safe DBs (e.g. PgVector), ConcurrentInsertRunner clamps
max_workers to 1, so there is always exactly one worker thread. There is
no need to deepcopy self.db per thread — the single worker can use
self.db directly via the connection already opened by task()'s
`with self.db.init():`.

The original code called deepcopy(self.db) inside _get_thread_db() after
task() had already opened a live psycopg C-extension Connection on
self.db. C-extension objects cannot be deep-copied, causing:
  TypeError: no default __reduce__ due to non-trivial __cinit__

Fix: remove the deepcopy branch entirely. All workers (thread-safe or
not) now use self.db directly; thread-safety is guaranteed for
non-thread-safe DBs by the max_workers=1 clamp.

Also clean up stale comments in pgvector.py left over from #760/#763.

Adds tests/test_pgvector.py with:
- unit test that reproduces the bug (fails on original, passes on fix)
- e2e regression test via ConcurrentInsertRunner + OpenAI 50K dataset

See also: #756

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
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.

4 participants