-
Notifications
You must be signed in to change notification settings - Fork 419
Concurrent queries on single connection #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You...can't run multiple queries concurrently on a single PostgreSQL connection. It's inherent to the protocol. |
The protocol does not allow parallel queries but "concurrent" queries could be queued. I'd expect asyncpg to wait for the "other operation" instead of raising that exception. I think it is a very important feature to allow coroutines to run in a single transaction. For example, to fulfill an order, a coroutine is started for each order line, then, after gathering all routines the order status will be updated and transaction get committed. Without running in a single transaction, complex two phase commit would be required. Of course there would be no benefit of the whole processing is done in SQL, but if the load is both SQL and application, some performance and parallelism would be gained. |
If you want proper concurrency, you should use a connection pool. The decision to crash loudly rather than "waiting" on concurrent queries to the same connection is deliberate. See #367 for a previous discussion. |
I am getting the same error with a We are evaluating CockroachDB to use in the company, and we can go without store procedures and other things, but this connection confusion is a no-no-no. What is the priority of this issue? Do you have an ETA about when it is going to be fixed? |
Not a maintainer, but I imagine this wouldn't be "fixed." PostgreSQL connections fundamentally run a single query at a time. (It is possible to pipeline queries. But that's relatively uncommon, and there are usually suitable alternatives.) |
The Cockroach issue is probably #580 (which should be fixed by cockroachdb/cockroach#83164) |
the issue with a local PostgreSQL install?: local PostgreSQL install
uvloop?: uvloop
Several queries are run concurrently and I receive the following error. What can I do to fix the problem ?
The text was updated successfully, but these errors were encountered: