Skip to content
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 race condition with use of PgVectorAgroalPoolInterceptor #727

Merged
merged 1 commit into from
Jul 8, 2024
Merged

Conversation

geoand
Copy link
Collaborator

@geoand geoand commented Jul 8, 2024

Prior to this, the application could open a connection that did not use the interceptor and then try and
reuse that connection against a PgVector database
without having the interceptor (as Agroal
would not take it into account because the connection was already open)

@geoand geoand requested a review from jmartisk July 8, 2024 09:48
@geoand geoand requested a review from a team as a code owner July 8, 2024 09:48
@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

Once this is in, I am going to do a release of 0.16.1 as this could easily be a blocker for development.

@jmartisk I think this interceptor should not be applied to the prod run, WDYT?

@jmartisk
Copy link
Collaborator

jmartisk commented Jul 8, 2024

@jmartisk I think this interceptor should not be applied to the prod run, WDYT?

By that you mean connections for any other datasource than the one configured for embedding storage? If so, then yeah.

@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

By that you mean connections for any other datasource than the one configured for embedding storage

I mean that from what I understand, this interceptor creates a type, which I think should not never be done by the framework in production (but it currently is).

Prior to this, the application could open a connection
that did not use the interceptor and then try and
reuse that connection against a PgVector database
without having the interceptor (as Agroal
would not take it into account because the connection
was already open)

Fixes: #726
@jmartisk
Copy link
Collaborator

jmartisk commented Jul 8, 2024

By that you mean connections for any other datasource than the one configured for embedding storage

I mean that from what I understand, this interceptor creates a type, which I think should not never be done by the framework in production (but it currently is).

But how else should it work? The application would have to register a similar interceptor by itself... Which would be annoying

@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

But how else should it work? The application would have to register a similar interceptor by itself... Which would be annoying

My point is that a production database would already be setup properly - in the same way you don't expect the application to create your relational schema

@jmartisk
Copy link
Collaborator

jmartisk commented Jul 8, 2024

But how else should it work? The application would have to register a similar interceptor by itself... Which would be annoying

My point is that a production database would already be setup properly - in the same way you don't expect the application to create your relational schema

For the database, sure, but this is not about the database, this is about registering an extension of the JDBC driver (client)

@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

Ah okay, I misunderstood it's functionality then - my bad!

@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

So this PR is ready then

@jmartisk
Copy link
Collaborator

jmartisk commented Jul 8, 2024

Ah, so IIUC it seems that actually the CREATE EXTENSION command is indeed server-side...
But the interceptor also calls

PGvector.addVectorType(connection);

which is the client-side setup.
So perhaps you're right and we could skip the CREATE EXTENSION part of the interceptor in production mode.

@jmartisk
Copy link
Collaborator

jmartisk commented Jul 8, 2024

The question is if it's really a big burden to have it executed, just to simplify things

@geoand
Copy link
Collaborator Author

geoand commented Jul 8, 2024

Thanks for checking further.

Let's leave it as is for now, and I'll open a new issue to keep the enhancement in mind for later.
I am going to assume we will need it because I believe lots of applications won't have the karma to do CREATE EXTENSION

@jmartisk jmartisk merged commit 6cf4c93 into main Jul 8, 2024
12 checks passed
@jmartisk jmartisk deleted the #726 branch July 8, 2024 11:48
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.

Using PGVector storage with Plain Hibernate Postgres breaks the Embeddings implementation
2 participants