feat: expose prepare_threshold parameter for connection pooler compatibility#6761
Open
veeceey wants to merge 1 commit intolangchain-ai:mainfrom
Open
feat: expose prepare_threshold parameter for connection pooler compatibility#6761veeceey wants to merge 1 commit intolangchain-ai:mainfrom
veeceey wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
…ibility External connection poolers (e.g., Google Cloud SQL connection pooler, PgBouncer in transaction mode) fail when prepare_threshold is hardcoded to 0, causing "prepared statement does not exist" errors. This change exposes the prepare_threshold parameter in all from_conn_string() methods to allow users to disable prepared statements when needed. Changes: - Add prepare_threshold parameter to PostgresSaver.from_conn_string() - Add prepare_threshold parameter to AsyncPostgresSaver.from_conn_string() - Add prepare_threshold parameter to ShallowPostgresSaver.from_conn_string() - Add prepare_threshold parameter to AsyncShallowPostgresSaver.from_conn_string() - Add tests for default (0), None, and custom threshold values - Default value remains 0 for backward compatibility Fixes langchain-ai#6705
Author
PR Review SummaryStatus: ✅ READY TO MERGEChanges Look Great! This PR properly exposes the parameter across all PostgreSQL saver classes, enabling compatibility with external connection poolers like Google Cloud SQL and PgBouncer. Key Strengths:
Test Coverage:
This is a well-executed feature addition that solves a real user pain point with connection poolers. Ready for merge! |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6705
External connection poolers (e.g., Google Cloud SQL connection pooler, PgBouncer in transaction mode) fail when
prepare_thresholdis hardcoded to0, causing "prepared statement does not exist" errors. This PR exposes theprepare_thresholdparameter in allfrom_conn_string()methods to allow users to disable prepared statements when needed.Changes
prepare_thresholdparameter to:PostgresSaver.from_conn_string()AsyncPostgresSaver.from_conn_string()ShallowPostgresSaver.from_conn_string()AsyncShallowPostgresSaver.from_conn_string()0for backward compatibilityUsage
Users can now set
prepare_threshold=Noneto disable prepared statements when using external connection poolers:Test plan
prepare_threshold=0(default)prepare_threshold=None(connection poolers)prepare_thresholdvaluesmake formatmake lint