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.94.2) (envelope-from ) id 1uCa8A-00H3W5-Pi for pgsql-general@arkaria.postgresql.org; Wed, 07 May 2025 08:27:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uCa89-00CVY5-Fw for pgsql-general@arkaria.postgresql.org; Wed, 07 May 2025 08:27:53 +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.94.2) (envelope-from ) id 1uCa88-00CVWy-WE for pgsql-general@lists.postgresql.org; Wed, 07 May 2025 08:27:53 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uCa86-000Ygz-0S for pgsql-general@lists.postgresql.org; Wed, 07 May 2025 08:27:51 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-39141ffa9fcso7086160f8f.0 for ; Wed, 07 May 2025 01:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1746606469; x=1747211269; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=jj+VIreGGxfBwGztlhRBj7yneHnsniOBXFCoGWfJ0Zg=; b=nA/ygk790yuCclUVTiSAaRo4rv+1ALrVAEXipxctbgx2vX7TdhErABzmYHSjvmmhKW pxP8TzY/KAcR8YlgGe2tLWqe4VKTGxgtm9f3ZilLr3GPBGYwz+/R84FiOYri6cYTM6ys xCyjgCz91qL4GxBp15YqjlFopSEXzOOQjq+DeJePaI9hsFIpBFo6l6CMTKWE50/EZkfO Ij1OMISljcm3juDr0jFVuNqP9CdY9f6kY7jPv7vPpmTnmasvMAHXkS0KuPWcyZj9A47o 27RBuSeerIEHRws4xlsd75d7CiPQ0IIfW9x9CG4pb1fo56ph+FRkHuzMdQfmg+SKxoyC 4Fag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746606469; x=1747211269; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jj+VIreGGxfBwGztlhRBj7yneHnsniOBXFCoGWfJ0Zg=; b=u6Y1zKsPEjUH+gA8Nbj5lyZ/03ZyfASKXWlYflv5KJM2xpwvQdu7+mT28omzFV4JEx j3WDimWG2VN6J1HZ9q5AN4f+6Nrs4HIsE8s5eUKEiASWE/5U6xIRUbUS7FVA9QGYMJax 8snS1uGhRxBxhIPgHlk4HnDA9o1IhJCwBRh86CgDC35ZFepFZ0fUP4uVeKMSOAdvQ08y ui9TjoPBQoYiaEbdy7Gr4uOriR41DBMfqBiTMIRvsdiDdr27iiAEh3pvS/CUDL6idPom QeviwFdwPrgKK3nF4x1iqE+iWEc7x9ikAeIHL5lYIK/yKibZURe4A5RBPk5piyfsM3yh pJBA== X-Forwarded-Encrypted: i=1; AJvYcCX1w4H6EvXk1XFemhQ93yo4s7pMcxU8lNCvuVQtSjgGoi39EaJV6pAp2TLt70lLK5iNIwEjilq+ktb7e2fc@lists.postgresql.org X-Gm-Message-State: AOJu0YyauFNOPIK3BbUwy3eC7agfQ9jwqUHtrOGCEimtsPC+eV8Nlj7+ zMejxgmcp9eWb+f+ivo37D8wlrk6KDfVq9ktIAllrYEpdETAP2ezD7EG5jmLQTg= X-Gm-Gg: ASbGncuMUaegmtTPAbXXo1THld5E7Kk8iboInpR94nq9PAC13chy/2N4SAN8j6qPsTJ 0t6kUDG9RRsY6KS0jo/oe7uORfsGsgJvoqMDMchGjGQE5ckypziX/Pqxjg3vAV2EXapkHtxhq1p 8At6+ru2rRr5FWJEJZ4+N4k2d8g4vSVXxcTCihZ4M+JUFw/RisMvNVExHPf9aOQjSvRMarIhIB7 7ZfuJvd1rs1V/2EQroXVkKioE2KtHqG6kR/dbNKMR08eMaXOqRWY7cM0h3ICO6duK1S/7sbbtMu SEk/cObUmh/OvM2v2qooD9A9hBT12JZInhlEpb3RjNZvOmd9wLyy7kci/CuIpHjzStFwfZ9RFv2 +Oea+mwE8qmG99cOEbkc= X-Google-Smtp-Source: AGHT+IElAq2UP18UWsagU83PBLIK3U28nyqnDjVZoh6vLrJGdAITlacP99qGcQnConZiKrqO4WG1IQ== X-Received: by 2002:adf:f28c:0:b0:3a0:b539:f330 with SMTP id ffacd0b85a97d-3a0b539f9eamr1302728f8f.2.1746606469135; Wed, 07 May 2025 01:27:49 -0700 (PDT) Received: from localhost.localdomain (ip-185-104-138-51.ptr.icomera.net. [185.104.138.51]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a0b350f604sm2692108f8f.21.2025.05.07.01.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 01:27:48 -0700 (PDT) Message-ID: <4c4246e7824aeec46e76afc95745fa1e28ac11b4.camel@cybertec.at> Subject: Re: Error in DROP TABLESPACE From: Laurenz Albe To: "Fagnani Gabriele G (GDS I&TS)" , "pgsql-general@lists.postgresql.org" Date: Wed, 07 May 2025 10:27:47 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2025-05-07 at 08:16 +0000, Fagnani Gabriele G (GDS I&TS) wrote: > INTERNAL ? > I've run into an odd problem - I have what seems to be a "zombie" tablesp= ace > that PostgreSQL won't let me drop, but nothing inside it is active. > =C2=A0 > drop tablespace ts_idx_wb2; > ERROR:=C2=A0 tablespace "ts_idx_wb2" is not empty > =C2=A0 > postgres=3D# \db+ ts_idx_wb2 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 List of tablespaces > =C2=A0=C2=A0=C2=A0 Name=C2=A0=C2=A0=C2=A0 |=C2=A0 Owner=C2=A0=C2=A0 |=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Locat= ion=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= |=C2=A0 Access privileges=C2=A0 | Options |=C2=A0 Size=C2=A0 | Description > ------------+----------+----------------------------------+--------------= -------+---------+--------+------------- > ts_idx_wb2 | postgres | /pgsql/postgres/tsdata1/ts_idx_wb2 | postgres=3DC= /postgres+|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 250 GB | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 | mydatabase=3DC/postgres |=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = | > (1 row) > =C2=A0 > Check on filesystem location. > On the filesystem there are files related only to fileref 515555188: > =C2=A0 > postgres@myserver:/pgsql/postgres/tsdata1/ts_idx_wb2/PG_12_201909212/1641= 9> ls -la > total 261854080 > drwx------ 2 postgres postgres=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 69632 Apr 22= 17:45 . > drwx------ 3 postgres postgres=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4096 O= ct 31=C2=A0 2024 .. > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.1 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.10 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.100 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.101 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.102 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.103 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.104 > ... > ... > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.97 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.98 > -rw------- 1 postgres postgres 1073741824 Oct 31=C2=A0 2024 515555188.99 > =C2=A0 > SELECT pg_tablespace_databases((SELECT oid FROM pg_tablespace WHERE spcna= me =3D 'ts_idx_wb2')); > pg_tablespace_databases > ------------------------- > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 16419 > =C2=A0 > =C2=A0 > SELECT oid, datname FROM pg_database WHERE oid =3D 16419; > oid=C2=A0 |=C2=A0 datname > -------+----------- > 16419 | mydatabase=C2=A0=C2=A0=C2=A0 <---------------- > =C2=A0 > =C2=A0 > Connected to database mydatabase: > =C2=A0 > select cl.relfilenode, nsp.nspname as schema_name, cl.relname, cl.relkind > from pg_class cl > =C2=A0 join pg_namespace nsp on cl.relnamespace =3D nsp.oid and cl.relfil= enode=3D515555188 ; > relfilenode | schema_name | relname | relkind > -------------+-------------+---------+--------- > (0 rows) > =C2=A0 > To be sure I run the same query on the other databases with the same resu= lt (0 rows) > =C2=A0 > So there are no actual references to these files, yet the relationship > persists sufficiently for the DROP TABLESPACE to error out. > My guess is that the files belong to an index being moved on Oct 31 to ts= _idx_wb2 tablespace, and during the move the > postgres instance crashed due space shortage on wal filesystem, and this = crash left this "zombie" files on the filesystem. > =C2=A0 > In order to drop the tablespace, is it safe to shut =C2=A0that postmaster= down and manually remove the contents of this > directory? Your diagnosis seems to be right, and I agree with your proposed remedy. Yours, Laurenz Albe