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

PGVector / Postgres connection is not automatically closed, and remains idle #151

Open
5 tasks done
Lengo46 opened this issue Jan 2, 2025 · 0 comments
Open
5 tasks done

Comments

@Lengo46
Copy link

Lengo46 commented Jan 2, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from datetime import datetime
from langchain_postgres import PGVector
from langchain_openai import OpenAIEmbeddings
from dotenv import load_dotenv

load_dotenv()

connection = os.getenv('POSTGRES_CONNECTION_STRING')  
embeddings = OpenAIEmbeddings(model="text-embedding-ada-002")

async def vectorStore(pg_table_name: str, remove = False):
    return PGVector(
        embeddings=embeddings,
        collection_name=pg_table_name,
        connection=connection,
        use_jsonb=True,
        pre_delete_collection=remove,
    )

### Error Message and Stack Trace (if applicable)

`psql: FATAL: remaining connection slots are reserved for non-replication superuser connections`

If I query the database, it's clearly that all connections remain idle and open.



### Description

This is a bug that was fixed in the past, see https://github.com/langchain-ai/langchain/issues/9696.  The PG Vector file has move to an import to  lanchain_postgres somewhere in the last year, which doesn't contain the fix for this issue.



### System Info

System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000
> Python Version:  3.11.1 (main, Jan  4 2023, 15:58:50) [Clang 14.0.0 (clang-1400.0.29.202)]

Package Information
-------------------
> langchain_core: 0.3.21
> langchain: 0.3.9
> langchain_community: 0.3.8
> langsmith: 0.1.135
> langchain_ollama: 0.2.0
> langchain_openai: 0.2.2
> langchain_postgres: 0.0.12
> langchain_text_splitters: 0.3.0

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.10.10
> async-timeout: 4.0.3
> dataclasses-json: 0.6.7
> httpx: 0.27.2
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> numpy: 1.26.4
> ollama: 0.3.3
> openai: 1.51.2
> orjson: 3.10.7
> packaging: 24.1
> pgvector: 0.2.5
> psycopg: 3.2.3
> psycopg-pool: 3.2.3
> pydantic: 2.10.4
> pydantic-settings: 2.5.2
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.35
> sqlalchemy: 2.0.35
> tenacity: 8.5.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2
@efriis efriis transferred this issue from langchain-ai/langchain Jan 2, 2025
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

No branches or pull requests

1 participant