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 1vKIRf-006Y1B-0E for pgsql-general@arkaria.postgresql.org; Sat, 15 Nov 2025 15:44:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vKIRa-009bKr-2q for pgsql-general@arkaria.postgresql.org; Sat, 15 Nov 2025 15:44:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vKIRa-009bKi-1j for pgsql-general@lists.postgresql.org; Sat, 15 Nov 2025 15:44:06 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vKIRY-007HP0-2T for pgsql-general@lists.postgresql.org; Sat, 15 Nov 2025 15:44:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5AFFhapX3351740; Sat, 15 Nov 2025 10:43:36 -0500 From: Tom Lane To: Ron Johnson cc: "Peter 'PMc' Much" , pgsql-general@lists.postgresql.org Subject: Re: failure to drop table due to pg_temp_7 schema In-reply-to: References: Comments: In-reply-to Ron Johnson message dated "Sat, 15 Nov 2025 10:28:18 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3351738.1763221416.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 15 Nov 2025 10:43:36 -0500 Message-ID: <3351739.1763221416@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson writes: > On Sat, Nov 15, 2025 at 10:00 AM Peter 'PMc' Much < > pmc@citylink.dinoex.sub.org> wrote: >> trying to unload (and then reload) a development application, >> failed with this error: >> >> fin(dev)> Que.migrate! version: 0 >> ERROR: cannot drop table que_jobs because other objects depend on it >> (PG::DependentObjectsStillExist) >> DETAIL: function pg_temp_7.lock_and_update_priorities(jsonb,que_jobs) >> depends on type que_jobs >> HINT: Use DROP ... CASCADE to drop the dependent objects too. >> Then, trying to figure out how this is supposed to be cleaned up, >> I find this article by subject matter expert Laurenz Albe: >> >> Temporary tables are automatically removed when the database >> session terminates. Consequently, your users are running long >> database sessions. >> >> Sadly, this does not make much sense to me, because there are >> (currently) no sessions on the database (checked with 'ps ax'). > Abnormal session termination is the typical reason for them to hang around. Yeah. I'd probably try to clean this up with (as superuser) DROP SCHEMA pg_temp_7 CASCADE; being sure that there is no other session that could be using that temp schema. There's no need to get rid of the pg_temp_NN schemas themselves; they are meant to hang around even when not in use, to reduce catalog thrashing. But any objects in them should have gone away at exit of the owning session. As Ron says, that's typically a consequence of an abnormal shutdown not affording any opportunity to drop the objects. It's normally harmless, because the next session that wants to use that schema is also expected to be willing to drop everything in it. There could be some deeper problem such as broken dependencies, in which case the recommended manual DROP SCHEMA would fail. But there's not evidence of that, yet. regards, tom lane