Skip to content

chore: Omit lock when using connection pool#6734

Merged
hinthornw merged 3 commits intomainfrom
wfh/unlock
Jan 31, 2026
Merged

chore: Omit lock when using connection pool#6734
hinthornw merged 3 commits intomainfrom
wfh/unlock

Conversation

@hinthornw
Copy link
Collaborator

@hinthornw hinthornw commented Jan 31, 2026

Thank you to Conrad for putting this up!

conradludgate and others added 3 commits January 30, 2026 16:21
…onnections (#6702)

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.
@hinthornw hinthornw enabled auto-merge (squash) January 31, 2026 00:26
@hinthornw hinthornw merged commit 193e128 into main Jan 31, 2026
62 checks passed
@hinthornw hinthornw deleted the wfh/unlock branch January 31, 2026 00:30
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

Successfully merging this pull request may close these issues.

2 participants