MagicStack / MagicStack/asyncpg

Trying to debug `asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress`

Open
#537 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

  • asyncpg version: 0.20.1
  • PostgreSQL version: 12
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : no
  • Python version: 3.7.5
  • Platform: OS X
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: -
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : yes

Hi!

I'm trying to debug an issue that I have with errors like asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress from this line: https://github.com/MagicStack/asyncpg/blob/dcef29804095990f25178b642b920f3fbcb4ca22/asyncpg/protocol/protocol.pyx#L664

I am trying to understand where I could have gone wrong. So, I would like to ask the following preliminary question:

Suppose my code interacts with asyncpg only through a pool, and only using context managers:

async with pool.acquire() as connection:
     ...

I also do not share the connection object around. On it, I use the methods fetchrow, fetchval and fetch. They are used sequentially from the same asyncio "thread" (for lack of better word). That is to say, they are never called in parallel.

In this setup, I would think that the error cannot perform operation: another operation is in progress never shows up, but it does. Am I missing something?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading asyncpg/protocol/protocol.pyx around line 664, then trace the pool.acquire context and the sequential fetchrow, fetchval, and fetch calls described in the report. Try to reduce the behavior to a reproducible example under asyncio and uvloop. Done means identifying the conflicting operation or documenting the missing reproduction details needed to diagnose it.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.