Find answers from the community

Updated 3 months ago

Sql

Any one have any idea why my tools would be failing? I'm using a locally hosted postgres database that's running via docker, and I'm connecting to it via the 0.0.0.0 ip address, and I'm getting sql errors like
Plain Text
=== Calling Function ===                                                                                                Calling function: Wiki_Tool with args: {"input":"smoother braking"}                                                     Got output: Error: (sqlalchemy.dialects.postgresql.asyncpg.InterfaceError) <class 'asyncpg.exceptions._base.InterfaceError'>: cannot perform operation: another operation is in progress                                                        [SQL: SELECT public.data_wiki_docs.id, public.data_wiki_docs.node_id, public.data_wiki_docs.text, public.data_wiki_docs.metadata_, public.data_wiki_docs.embedding <=> $1 AS distance                                                           FROM public.data_wiki_docs ORDER BY distance asc                                                                         LIMIT $2::INTEGER]                                                                                                     [parameters: ('[-0.04321499168872833,-0.008070970885455608,0.038734838366508484,0.034068379551172256,-0.03698354959487915,0.08398095518350601,-0.007821937091648579, ... (7816 characters truncated) ... -0.027220504358410835,-0.04467884078621864,0.007395491935312748,-0.04819626361131668,0.009278454817831516,0.012993157841265202,-0.007883192971348763]', 5)]    (Background on this error at: https://sqlalche.me/e/20/rvf5)                                                            ========================
L
i
t
29 comments
I actually have no idea πŸ‘€
not sure if this would help
I wonder if it's cause I'm using tools?
@Logan M do tools do parallel requests by default?
they definitely would. If the tool is sharing the same instance of sqlalchemy, I could see that causing this issue
Any ideas on how to get around this?
no idea -- it would be specific to sqlalchemy. Maybe theres some locking setting?

Or, you need to create a fresh reference to sqlalchmey instead of using some global for the tool
wdym create a fresh reference?
Sorry, I'm still very new to the whole sql data base stuff
I got it 'working' and then moved on, and now I'm getting more errors with the more complex tools
It seems like theres some shared global instance of your db, and when a tool gets called in parallel, it causes the issue (this is all me guessing based on what I've seen here lol)
Would you mind looking at the code?
Cause you might be right, but I'm just raw doggin the world
oh shit... maybe it's create_query_engine
Maybe my entire tool setup is fucked...
yea seems like you only create one postgres connection and leave it as a global
and then sqlalchemy freaks out
hm... okay, I guess I can split it all up? But that'll make multiple connections, should be fine tho right?
I think its fine? I know you can setup connection pooling... somehow lol
yah, I tried, but it seemed like llama index did it by default, but I couldn't figure it out
Okay, I asked gpt, and it spit out some shit about doing a schema for each tool and then using pooling for that or something... idk, but once the db is built, I'ma try it
Well, time to push into testing
will update when I remember
I'm giving up on postgresql, I'll try elastisearch at some point
Add a reply
Sign up and join the conversation on Discord