Engine object is not being properly disposed in PGVector #51

Open
opened 2026-02-16 05:16:18 -05:00 by yindo · 0 comments
Owner

Originally created by @ladi-pomsar on GitHub (Oct 14, 2024).

Hi everyone,

In #64 del method (lines 326-328) was removed from VectorStores.PGVector. While, after a bit of investigation, I believe this was a right decision, I would say it might need to be reintroduced. The way code currently is, the Engine object (stored in self._engine) doesn't dispose properly, upon deletion, if it is initialized from string by user through the connection parameter (as for lines 432 to 438).

I have faced "too many connections" error that seem to be fixed by disposing the engine with .dispose.

Originally created by @ladi-pomsar on GitHub (Oct 14, 2024). Hi everyone, In #64 __del__ method ([lines 326-328](https://github.com/langchain-ai/langchain-postgres/pull/32/files#diff-b4e539a359bed41ba8f4652fb8562e046ceaf1aaa8c0b5c2533fb43f629ab0feL326-L328)) was removed from VectorStores.PGVector. While, after a bit of investigation, I believe this was a right decision, I would say it might need to be reintroduced. The way code currently is, the Engine object (stored in self._engine) doesn't dispose properly, upon deletion, if it is initialized from string by user through the connection parameter ([as for lines 432 to 438](https://github.com/langchain-ai/langchain-postgres/blob/main/langchain_postgres/vectorstores.py#L432-L438)). I have faced "too many connections" error that seem to be fixed by disposing the engine with .dispose.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#51