drop tablespace error: invalid argument - Mailing list pgsql-hackers

From Jan Otto
Subject drop tablespace error: invalid argument
Date
Msg-id 47C45B07-8459-48D8-8FBE-291864019CC2@me.com
Whole thread Raw
Responses Re: drop tablespace error: invalid argument  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
hello hackers,

i have problems dropping an existing empty tablespace. here is a reduced example:

AscheMobil:~ asche$ cat test2.sql 
CREATE TABLESPACE testspace LOCATION '/opt/postgresql/data2';
CREATE SCHEMA testschema;
CREATE TABLE testschema.foobar (id int) TABLESPACE testspace;
DROP SCHEMA testschema CASCADE;
DROP TABLESPACE testspace;

AscheMobil:~ asche$ /opt/postgresql/bin/psql asche <test2.sql 
CREATE TABLESPACE
CREATE SCHEMA
CREATE TABLE
NOTICE:  drop cascades to table testschema.foobar
DROP SCHEMA
ERROR:  could not read directory "pg_tblspc/16464": Invalid argument
STATEMENT:  DROP TABLESPACE testspace;
ERROR:  could not read directory "pg_tblspc/16464": Invalid argument

AscheMobil:~ asche$ ls -l /opt/postgresql/data/pg_tblspc/
total 8
lrwx------  1 asche  staff  21 Aug 16 13:08 16464 -> /opt/postgresql/data2

AscheMobil:~ asche$ ls -l /opt/postgresql/data2/
total 8
-rw-------  1 asche  staff  4 Aug 16 13:08 PG_VERSION

AscheMobil:~ asche$ id
uid=501(asche) gid=20(staff) groups=20(staff),204(_developer),100(_lpoperator),98(_lpadmin),81(_appserveradm),80(admin),79(_appserverusr),61(localaccounts),12(everyone),402(com.apple.sharepoint.group.1),401(com.apple.access_screensharing)

if i dont create the table testschema.foobar i can drop the tablespace without problems. there is another effect i wonder about. when i execute 'DROP TABLESPACE testspace;' two times at the end of script the second drop statement drops the tablespace correctly.

AscheMobil:~ asche$ echo 'DROP TABLESPACE testspace;'>>test2.sql 
AscheMobil:~ asche$ cat test2.sql 
CREATE TABLESPACE testspace LOCATION '/opt/postgresql/data2';
CREATE SCHEMA testschema;
CREATE TABLE testschema.foobar (id int) TABLESPACE testspace;
DROP SCHEMA testschema CASCADE;
DROP TABLESPACE testspace;
DROP TABLESPACE testspace;

AscheMobil:~ asche$ /opt/postgresql/bin/psql asche < test2.sql 
CREATE TABLESPACE
CREATE SCHEMA
CREATE TABLE
NOTICE:  drop cascades to table testschema.foobar
DROP SCHEMA
ERROR:  could not read directory "pg_tblspc/16469": Invalid argument
STATEMENT:  DROP TABLESPACE testspace;
ERROR:  could not read directory "pg_tblspc/16469": Invalid argument
DROP TABLESPACE

AscheMobil:~ asche$ ls -l /opt/postgresql/data2/
AscheMobil:~ asche$ ls -l /opt/postgresql/data/pg_tblspc/

AscheMobil:~ asche$ /opt/postgresql/bin/psql asche -c 'select version()'
                                                                version                                                                 
----------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.0 on i386-apple-darwin10.0.0, compiled by GCC i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646), 64-bit
(1 row)

this is the original postgresql-8.4.0 source package from http://www.postgresql.org/ftp/source/v8.4.0/ compiled with:
./configure --enable-debug --with-openssl --with-perl --with-python --with-tcl --with-libxml --with-libxslt --with-zlib --prefix=/opt/postgresql

it would be nice if somebody can take a look at this. 

regards, jan otto

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: GRANT ON ALL IN schema
Next
From: Peter Eisentraut
Date:
Subject: Re: freezing tuples ( was: Why is vacuum_freeze_min_age 100m? )