pg.ddx.io  psycopg/psycopg GitHub issues and pull requests  
help / color / mirror / Atom feed
From: JulienPalard (@JulienPalard) <noreply+JulienPalard@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: Re: [psycopg/psycopg] issue #1427: Hang in futex, linked to garbage collection
Date: Mon, 28 Sep 2026 11:39:42 +0000
Message-ID: <gh-psycopg-psycopg-1427-c5869112525@github.com> (raw)
In-Reply-To: <gh-psycopg-psycopg-1427@github.com>
References: <gh-psycopg-psycopg-1427@github.com>

As far as I understand now: during a psycopg.cursor.execute,  while the lock is held, a GC triggers, leading to a call to _server_cursor.close, which tries to take the lock but can't. The GC pass never ends, deadlocking the thread.

Can easily be shown by using:

```
import gc
gc.set_debug(gc.DEBUG_STATS)`
```

showing this at the end of a locked process:
```
gc: collecting generation 0...
gc: objects in each generation: 2144 8269 343198
gc: objects in permanent generation: 0
```

A normal GC run ends with `gc: done, 35 unreachable, 0 uncollectable, 0.0010s elapsed`.



view thread (10+ messages)  latest in thread

Message-ID: <gh-psycopg-psycopg-1427-c5869112525@github.com>
Permalink:  ../gh-psycopg-psycopg-1427-c5869112525@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox