Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xGJcw-00000002Dvi-3oeV for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Oct 2026 17:15:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xGJcv-00000009cBL-0dda for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Oct 2026 17:15:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xGF6c-00000008V1H-3VJq for pgsql-bugs@lists.postgresql.org; Mon, 12 Oct 2026 12:26:14 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xGF6X-00000001hLI-3G84 for pgsql-bugs@lists.postgresql.org; Mon, 12 Oct 2026 12:26:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=ERvFDpQqnZ7HnkuzNA1A/RQeHG51vFgNoc+KySXX2Nc=; b=HynnEpTv1rFXIQj+2wW5iOvjXd 07mFNZUvkeFaw75j4hfz+ggLekWqnVluQXfroGzYZbRvSDpILGLGfIfnt6lSQOIuAHTFd1ACbOxX+ OcpAiPudgKCwpguyaDRo4RdYZJ8XFEehAPq1LLwqFwDdHbiVfPcCazLbpPkQiDx65xyx4+T74uhx2 K9nRAY7TgiL9FWsFMcalYUlkf8XES3F++g9mgFzNsj9TUZfi18ua0UOG2Ph0AGQBjEuanyL6QWnFJ vlT7y/bcyzDaBe9KeSWsoZcBYsV+DbhSMovoRO0y1zgCr6YHr4T8GzYfbfcubjGBj050j4/1Tci1E AasHP5vg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xGF6T-00000004qIl-1X0q for pgsql-bugs@lists.postgresql.org; Mon, 12 Oct 2026 12:26:08 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xGF6R-0000000EvSJ-3DXq for pgsql-bugs@lists.postgresql.org; Mon, 12 Oct 2026 12:26:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19755: Server-wide hang: DROP DATABASE waits forever for ProcSignalBarrier while VACUUM waits on pg_databas To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: anncalla@163.com Reply-To: anncalla@163.com, pgsql-bugs@lists.postgresql.org Date: Mon, 12 Oct 2026 12:25:57 +0000 Message-ID: <19755-6ffb2ecb4e3fd782@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19755 Logged by: Ann Calla Email address: anncalla@163.com PostgreSQL version: 18.6 Operating system: Ubuntu 24.04 x86_64 Description: =20 Description ----------- With several sessions concurrently running DROP DATABASE / CREATE DATABASE and database-wide VACUUM FULL in other databases, the server can enter a state that it never leaves: * DROP DATABASE logs, every 5 seconds and indefinitely, LOG: still waiting for backend with PID 1770 to accept ProcSignalBarrier STATEMENT: DROP DATABASE IF EXISTS sN * the backend it names is a VACUUM that is waiting for a heavyweight lock ("VACUUM waiting" in the process title); * every other VACUUM / ANALYZE / CREATE DATABASE, the autovacuum launcher and all new connections ("startup waiting") queue up behind it, so the server accepts no new sessions; * no "deadlock detected" error is raised; * the named VACUUM backend does not react to SIGTERM (pg_terminate_backend equivalent) or to a manual SIGUSR1. Only a server restart recovers. We first hit this with an automated test workload (8 client sessions, one database per session); the server stayed in this state for more than 24 hours until it was restarted. How to reproduce ---------------- On a freshly initialised cluster, run the attached repro.sh inside the server container (it only needs psql and a trusted local superuser): docker run -d --name pg -e POSTGRES_HOST_AUTH_METHOD=3Dtrust postgres:latest docker cp repro.sh pg:/repro.sh docker exec -u postgres pg bash /repro.sh 300 docker logs pg 2>&1 | grep ProcSignalBarrier The script starts 12 sessions. Each one loops over: DROP DATABASE IF EXISTS sN; CREATE DATABASE sN; -- connected to "test" -- then, connected to sN: a few CREATE TABLE / INSERT statements, CREATE TEMP VIEW ...; ANALYZE; TRUNCATE t3; DISCARD TEMP; VACUUM FULL; VACUUM; On a fresh cluster the hang appeared within two minutes in 2 of 2 runs. It is timing dependent: on a cluster that had already been through a restart, two runs of 4 and 9 minutes did not hang. The same workload with "VACUUM FULL t0; VACUUM FULL t1; ..." (table-level) instead of the database-wide "VACUUM FULL" ran for 6 minutes without hanging. Stack traces ------------ Taken with gdb from the hung server (no debug symbols; full output of all backends is attached as stacks.txt). The DROP DATABASE backend: epoll_wait <- WaitEventSetWait <- WaitLatch <- ConditionVariableTimedSleep <- WaitForProcSignalBarrier <- dropdb <- standard_ProcessUtility The backend it is waiting for (PID 1770), and five other VACUUM backends: epoll_wait <- WaitEventSetWait <- WaitLatch <- ProcSleep <- LockAcquireExtended <- LockRelationOid <- relation_open <- table_open <- vac_update_datfrozenxid <- vacuum <- ExecVacuum Four further VACUUM backends: ... ProcSleep <- LockAcquireExtended <- LockRelationOid <- try_relation_open <- vacuum_open_relation <- vacuum <- ExecVacuum CREATE DATABASE: ... ProcSleep <- LockAcquireExtended <- LockRelationOid <- relation_open <- table_open <- createdb Analysis (from reading the source; not confirmed with a debug build) --------------------------------------------------------------------- vac_update_datfrozenxid() calls vac_truncate_clog(), which is static and appears to be inlined in this build. vac_truncate_clog() does LWLockAcquire(WrapLimitsVacuumLock, LW_EXCLUSIVE); ... relation =3D table_open(DatabaseRelationId, AccessShareLock); so the heavyweight lock on pg_database is requested while an LWLock is held, i.e. with interrupts held off. If that request has to wait, the backend can neither absorb a ProcSignalBarrier nor be cancelled or terminated. That would give this cycle, which the deadlock detector cannot see because one edge is not a heavyweight lock: A: DROP DATABASE holds RowExclusiveLock on pg_database, waits in WaitForProcSignalBarrier() for B B: VACUUM holds WrapLimitsVacuumLock (interrupts held off), waits for AccessShareLock on pg_database behind C C: VACUUM FULL (database-wide, now processing pg_database) waits for AccessExclusiveLock on pg_database, blocked by A This matches the observations that the named backend ignores SIGTERM and that the hang needs a database-wide VACUUM FULL, the only statement in the workload that requests AccessExclusiveLock on pg_database. Expected behaviour ------------------ DROP DATABASE should complete, or one of the participants should fail with an error. A lock wait on pg_database should not be uninterruptible.