-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add schema name if dropping index in pgvector store #1277
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I agree with the change, but I found some opportunities for improvement.
index_exists_after_deletion = bool( | ||
self._execute_sql( | ||
"SELECT 1 FROM pg_indexes WHERE schemaname = %s AND tablename = %s AND indexname = %s", | ||
(self.schema_name, self.table_name, self.hnsw_index_name), | ||
"Could not check if HNSW index exists", | ||
).fetchone() | ||
) | ||
|
||
if index_exists and index_exists_after_deletion: | ||
error_message = "The HNSW was not dropped" | ||
raise DocumentStoreError(error_message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this check.
If the HNSW index is not dropped, the following invocation self._create_hnsw_index()
will fail. Right?
|
||
|
||
@pytest.mark.integration | ||
def test_hnsw_index_recreation_in_new_schema(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test can be improved/changed.
I would probably first create a Document Store instance,
then create another one with hnsw_recreate_index_if_exists=True
and verify in some way that the HNSW index is first dropped and then recreated.
I can help with the implementation, if needed.
Related Issues
Proposed Changes:
In pgvector if HNSW index should drop, only index_name was used, but not schema_name. So if there were multiple schemas, the index was not dropped and could not be recreated.
How did you test it?
The check was added directly to the code, so if the index existed and should be dropped, the Error is raised, because I consider it as critical Error.
Notes for the reviewer
I tested this on multiple machines with similar setups, and the behavior was not consistent. On one PC this fix was needed, but on the other PC this fix was not needed, and it was working even without the fix, but I was not able to discover the difference...
But I believe that the fix is correct, and should be applied.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.