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

From Jan Otto
Subject Re: drop tablespace error: invalid argument
Date
Msg-id A7100E92-9E7F-438C-B4A4-17927C56D142@me.com
Whole thread Raw
In response to Re: drop tablespace error: invalid argument  (Jan Otto <asche@me.com>)
Responses Re: drop tablespace error: invalid argument  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Jan Otto <asche@me.com> writes:
ERROR:  could not read directory "pg_tblspc/16464": Invalid argument
STATEMENT:  DROP TABLESPACE testspace;

I have digged a bit around in the source code of postgresql to build a
self contained test-case for Apple and found that the implementation
of Apples readdir() is buggy. readdir() fails under some circumstances.
So i have build a patch against current pgsql's HEAD to work around
the issue. If the bug in readdir() goes into the final release  snow leopard
we have a solution. 

This patch basically frees dirdesc and rereads the tablespace location
in case a subdirectory was deleted from the tablespace. this is the place
where snow leopard fails to read the next entry with readdir().

The bug in readdir() appeared in the final snow leopard too. Anybody
with Snow Leopard installed can check this, with simply doing the regression
tests (make check). The tablespace regression test is failing.

The patch i sent in works around the issue. if it is not acceptable to reread
the tablespace-directory after every delete i can rewrite the workaround.
Probably it is preferred that we write all entries of the directory into an array 
and looping through that array after that instead of looping with ReadDir()?

regards, jan otto 

pgsql-hackers by date:

Previous
From: Stefan Kaltenbrunner
Date:
Subject: Re: LWLock Queue Jumping
Next
From: Grzegorz Jaskiewicz
Date:
Subject: Re: clang's static checker report.