Closed alexanderflorean closed 2 months ago
Also, I found after posting this issue, a similar issue #86, where it was recommended to use the psycopg3
engine whereas I'm using asyncpg
.
However, switching to psycopg3
, I recived the following error:
sqlalchemy.exc.InterfaceError: (psycopg.InterfaceError) Psycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())' (Background on this error at: https://sqlalche.me/e/20/rvf5)
I tried to fix that error, using the following, as stated in the error:
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
This did not fix the issue, when using the psycopg3
engine.
Could you provide the stack trace?
Closing as issue appears stale
Description
When running the retriever in
langchain-postgres
as an asynchronous instance, I encounter the following error, related to the SQL statement execution. The message suggests that the problem arises from attempting to insert multiple SQL commands into a prepared statement, which seems to not be supported.Error Message
My thoughts
The error appears to be caused by the SQL statement that combines two commands: acquiring an advisory lock and creating an extension, executed as a single statement, even though it is separated by ";" in the sql text statement. This is seems to not be supported in asynchronous execution with
asyncpg
as it treats this as a syntax error in a prepared statement.Proposed Solution
I found that if the SQL commands are defined as separate statements, we avoids combining multiple commands into a single execution call.
The affected code, in
vectorstore.py:236
:Here is the revised function implementation that fixed the issue for me:
By separating the statements into individual execution calls, the error is avoided, and the functionality remains intact. Although I haven't tried using it on a synchronous instance.
Question
Would love to get some feedback as I do not often post on issues. Shoud I create a pr for this fix to the issue?