MagicStack / MagicStack/asyncpg

Cockroachdb unimplemented feature multiple active portals not supported

Offen
#580 19 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
8.1k
Forks
468
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

  • asyncpg version: 0.20.1
  • Cockroachdb version: v20.1.0 (connected to a 5-node on premise cluster)
  • Python version: 3.8.0
  • Platform: Linux
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes

Example code:


    async with pool.acquire() as conn:
        async with conn.transaction():
            if not await conn.table_exists("sys_app_config"):
                await conn.execute("""
                    CREATE TABLE sys_app_config(
                        key  text NOT NULL PRIMARY KEY,
                        value jsonb
                    );
                """)

The table_exists method looks like this:


class MyConnection(Connection):
    async def table_exists(self, table_name: str) -> bool:
        """Tell if a table exists."""
        return await self.fetchval(
            "select table_name from information_schema.tables where table_name=$1", table_name) is not None

This code is actually called from tornado.ioloop.IOLoop.current().run_sync so it is guaranteed that nothing else is running queries concurrently.

Here is the traceback that I'm getting:


 File "/home/user/my_project/db/initialize.py", line 19, in init_database
    if not await conn.table_exists("sys_app_config"):
  File "/home/user/.local/share/virtualenvs/backend-YgzYW8Ky/lib/python3.8/site-packages/asyncpg/transaction.py", line 91, in __aexit__
    await self.__commit()
  File "/home/user/.local/share/virtualenvs/backend-YgzYW8Ky/lib/python3.8/site-packages/asyncpg/transaction.py", line 179, in __commit
    await self._connection.execute(query)
  File "/home/user/.local/share/virtualenvs/backend-YgzYW8Ky/lib/python3.8/site-packages/asyncpg/connection.py", line 272, in execute
    return await self._protocol.query(query, timeout)
  File "asyncpg/protocol/protocol.pyx", line 316, in query
asyncpg.exceptions.FeatureNotSupportedError: unimplemented: multiple active portals not supported
HINT:  You have attempted to use a feature that is not yet implemented.
See: https://github.com/cockroachdb/cockroach/issues/40195

The referenced issue tells that it is not possible to keep multiple queries open and fetch from them interleaved.

However, I'm not doing anything that should result in opening multiple queries and fetching from them that way. As far as I see, my code should not open a new query before closing the previous one.

I suspect that asyncpg itself forgot to close something in the background.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Transaktions-Commit-Pfad in asyncpg/transaction.py und untersuche anschließend asyncpg/connection.py sowie asyncpg/protocol/protocol.pyx im Umfeld von execute und query. Reproduziere das table_exists-Beispiel mit der angegebenen CockroachDB-Konfiguration und verfolge, ob der Treiber vor dem Commit ein aktives Portal offen lässt. Erledigt bedeutet, das Verhalten des Treibers zu identifizieren oder die Inkompatibilität der Datenbank zu bestätigen und die Belege zu dokumentieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
postgresql, python
Bereich
backend, databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.