-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Labels
enhancementNew feature or requestNew feature or request
Description
Privileged issue
- I am a LangGraph maintainer, or was asked directly by a LangGraph maintainer to create an issue here.
Issue Content
Problem
When using AsyncPostgresSaver.from_conn_string() with external connection poolers (e.g., Google Cloud SQL connection pooler, PgBouncer in transaction mode), users encounter "prepared statement does not exist" errors:
prepared statement "_pg3_3" does not exist
This occurs because prepare_threshold=0 is hardcoded, which still uses the extended query protocol. Setting prepare_threshold=None resolves the issue.
Proposed Solution
Expose prepare_threshold as an optional parameter:
@classmethod
@asynccontextmanager
async def from_conn_string(
cls,
conn_string: str,
*,
pipeline: bool = False,
serde: SerializerProtocol | None = None,
prepare_threshold: int | None = 0, # New parameter
) -> AsyncIterator[AsyncPostgresSaver]:Current Workaround
from psycopg import AsyncConnection
from psycopg.rows import dict_row
from langgraph.checkpoint.postgres import AsyncPostgresSaver
async with await AsyncConnection.connect(
conn_string, autocommit=True, prepare_threshold=None, row_factory=dict_row
) as conn:
checkpointer = AsyncPostgresSaver(conn)Additional Context
This applies to PostgresSaver, ShallowPostgresSaver, and AsyncShallowPostgresSaver as well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request