Conversation
Co-authored-by: jason0916phoenix <jason0916phoenix@gmail.com>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| try: | ||
| conn_list.remove(connection) | ||
| except ValueError: | ||
| pass |
There was a problem hiding this comment.
Race condition causes KeyError in idle check task
In ClusterConnectionPool.disconnect_on_idle_time_exceeded(), the access to _created_connections_per_node[node['name']] at line 369 is unprotected, while the similar access to _available_connections was made safe with .get() and try/except. The new disconnect() method clears _created_connections_per_node = {} after calling task.cancel(), but cancellation only raises CancelledError at the next await point. Since there's no await between the condition check and the decrement, a racing idle check task can attempt to access the cleared dict, causing a KeyError. The decrement needs the same protection pattern as the list removal above it.
Fixes critical bugs and modernizes asyncio usage for improved robustness and compatibility.
This PR addresses several P0 issues identified in the project, including:
loop=parameters from asyncio calls to ensure compatibility with Python 3.8+.awaitlogic for asynchronous callbacks in pipelines.Cache.delete_pattern's SCAN cursor handling.disconnect()operations more idempotent.PubSubWorkerThreadto useconcurrent.futures.waitinstead of deprecatedasyncio.wait(loop=...).Note
Modernizes asyncio integration and fixes several correctness issues across cache, pipeline, connections, pools, and pubsub.
loop=parameters (asyncio.sleep,open_connection,open_unix_connection, timeouts, thread waits) gated byLOOP_DEPRECATED; usesconcurrent.futures.waitinPubSubWorkerThread.stopCache.delete_patternSCAN loop: startcursor=0, iterate untilcursor==0, and guard deletes when no identitiesinspect.isawaitable(r)Connection.connect()now raisesConnectionErrorwith exception chaining (from exc)disconnect(), and fully reset internal state; make cluster pool variants consistent and resilient to missing entries during removalLocksleep; minor cleanups to avoid negative counters and ensure idempotent disconnect behaviorWritten by Cursor Bugbot for commit 61f0b8a. This will update automatically on new commits. Configure here.