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.96) (envelope-from ) id 1w6nGJ-004esc-04 for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 10:20:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6nGH-00G81Q-1v for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 10:20:54 +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.96) (envelope-from ) id 1w6mwE-00G65F-1R for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 10:00:10 +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 1w6mwB-00000001nlP-0j04 for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 10:00:10 +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=jgVKJqlr3d2vkURyjyjuzblQrZfQ2ul7jlfQCt9RSIg=; b=lSbUz5GGCxrkIBpfoTM1lsbIG7 IZtpc8f77sPXKVHpZWiObZYxgXwef9+DfAIm4SFOjKBMyjA0LoAVUVB2EG5AwdhNXNxr4XrYEKdpZ MeFrWxFzrY3AUO4VWE8zNi/Q7+D85mNFygsE+sKuef3I/HiolFPLghRCdsrIR/T770aTYz/upGZtk ABl/y0NW2rKA9jwxNkI9SGn1GV4mHJ0otF2CIW+s+6U5YTBD5tqTyI3MgkA3Roqkc9d9OBhDARhm4 RYbuE9D4Sb0mhOYBXFRlDSspJiDrJismc/9nPHWhbRSsmmHZaqxLGSfAQO6qCfZtzgAqkOaYI8A4R 7dd/uhEw==; 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.96) (envelope-from ) id 1w6mwA-006DtE-0S for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 10:00:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6mw7-009Ypn-0E for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 10:00:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19441: Backend waits for serializable snapshot indefinitely on removing temp relations To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: exclusion@gmail.com Reply-To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Date: Sun, 29 Mar 2026 10:00:01 +0000 Message-ID: <19441-ec29f3b1363b4a68@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: 19441 Logged by: Alexander Lakhin Email address: exclusion@gmail.com PostgreSQL version: 18.3 Operating system: Ubuntu 24.04 Description: =20 The following script: echo " CREATE TEMPORARY TABLE tt (i int); SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE; SELECT pg_sleep(2); " | psql & sleep 1 echo " CREATE TABLE t (i int); BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE; INSERT INTO t VALUES (1); PREPARE TRANSACTION 'pt'; " | psql wait psql -c "SELECT pid, pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE backend_type=3D'client backend' AND query NOT LIKE '%pg_stat_activity%'" sleep 5 psql -c "SELECT * FROM pg_stat_activity WHERE backend_type=3D'client backen= d' AND query NOT LIKE '%pg_stat_activity%'" (with max_prepared_transactions =3D 1 in postgresql.conf) instantiates a backend hanging on exit, waiting for a snapshot: pid | pg_terminate_backend ---------+---------------------- 2143677 | t gdb -p 2143677 (gdb) bt #0 0x000077c27fb2a007 in epoll_wait (epfd=3D5, events=3D0x5d3d166cd868, maxevents=3D1, timeout=3Dtimeout@entry=3D-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30 #1 0x00005d3ce11b11d2 in WaitEventSetWaitBlock (set=3Dset@entry=3D0x5d3d166cd800, cur_timeout=3Dcur_timeout@entry=3D-1, occurred_events=3Doccurred_events@entry=3D0x7ffeb661f160, nevents=3Dnevents@entry=3D1) at waiteventset.c:1193 #2 0x00005d3ce11b1bd4 in WaitEventSetWait (set=3D0x5d3d166cd800, timeout=3Dtimeout@entry=3D-1, occurred_events=3Doccurred_events@entry=3D0x7ffeb661f160, nevents=3Dnevents@entry=3D1, wait_event_info=3Dwait_event_info@entry=3D134217779) at waiteventset.c:= 1141 #3 0x00005d3ce11a4b78 in WaitLatch (latch=3D, wakeEvents=3DwakeEvents@entry=3D33, timeout=3Dtimeout@entry=3D0, wait_event_info=3Dwait_event_info@entry=3D134217779) at latch.c:196 #4 0x00005d3ce11c8188 in ProcWaitForSignal (wait_event_info=3Dwait_event_info@entry=3D134217779) at proc.c:2005 #5 0x00005d3ce11c42bf in GetSafeSnapshot (origSnapshot=3DorigSnapshot@entry=3D0x5d3ce17753e0 ) at predicate.c:1600 #6 0x00005d3ce11c4436 in GetSerializableTransactionSnapshot (snapshot=3Dsnapshot@entry=3D0x5d3ce17753e0 ) at predicate.c:1716 #7 0x00005d3ce137077d in GetTransactionSnapshot () at snapmgr.c:320 #8 0x00005d3ce0e67c65 in RemoveTempRelationsCallback (code=3D, arg=3D) at namespace.c:4703 #9 0x00005d3ce11a3cad in shmem_exit (code=3Dcode@entry=3D0) at ipc.c:250 #10 0x00005d3ce11a3da6 in proc_exit_prepare (code=3Dcode@entry=3D0) at ipc.= c:199 #11 0x00005d3ce11a3e3c in proc_exit (code=3Dcode@entry=3D0) at ipc.c:112 #12 0x00005d3ce11d7c07 in PostgresMain (dbname=3D, username=3D) at postgres.c:5046 #13 0x00005d3ce11d0fac in BackendMain (startup_data=3D, startup_data_len=3D) at backend_startup.c:124 ... Reproduced starting from 7c38ef2a5.