[PR #6702] fix(checkpoint-postgres): skip acquiring the lock when using pooled connections #5232

Closed
opened 2026-02-20 17:51:25 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6702

State: closed
Merged: Yes


When using an AsyncConnectionPool, connections are most likely† never shared by _cursor(). Calling AsyncConnectionPool.connection() removes the connection from the pool, so it cannot be used by any concurrent calls. As such, the lock inside _cursor() is redundant.

If the pool allows more than one connection, then _cursor() should be allowed to be concurrently called. As far as I can tell, the only way for that to occur is between _execute_batch() and sweep_ttl().

In the current setup, if the sweep_ttl() operation is slow, then that delays all batch operations. This might be the trigger of the behaviour I was seeing in #6701.

† In theory, someone could implement AsyncConnectionPool to return a shared connection, but that would be redundant in langgraph.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6702 **State:** closed **Merged:** Yes --- When using an `AsyncConnectionPool`, connections are most likely† never shared by `_cursor()`. Calling `AsyncConnectionPool.connection()` removes the connection from the pool, so it cannot be used by any concurrent calls. As such, the lock inside `_cursor()` is redundant. If the pool allows more than one connection, then `_cursor()` should be allowed to be concurrently called. As far as I can tell, the only way for that to occur is between `_execute_batch()` and `sweep_ttl()`. In the current setup, if the `sweep_ttl()` operation is slow, then that delays all batch operations. This might be the trigger of the behaviour I was seeing in #6701. † In theory, someone could implement `AsyncConnectionPool` to return a shared connection, but that would be redundant in langgraph.
yindo added the pull-request label 2026-02-20 17:51:25 -05:00
yindo closed this issue 2026-02-20 17:51:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#5232