Re: drop tablespace error: invalid argument

From: Jan Otto <asche(at)me(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: drop tablespace error: invalid argument
Date: 2009-08-17 23:00:51
Message-ID: 5A2BBE87-8F76-4737-BE66-F83994777474@me.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Aug 16, 2009, at 8:25 PM, Tom Lane wrote:
> Jan Otto <asche(at)me(dot)com> writes:
>> ERROR: could not read directory "pg_tblspc/16464": Invalid argument
>> STATEMENT: DROP TABLESPACE testspace;
>
> Hmm ... can't reproduce this here, not even on OSX. From the version
> number I suspect you are using unreleased Snow Leopard. I'd venture
> it's a newly-introduced kernel bug and you need to talk to Apple about
> it.
>
> regards, tom lane

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().

regards, jan otto

diff -c -r1.61 tablespace.c
*** pgsql/src/backend/commands/tablespace.c 22 Jan 2009 20:16:02
-0000 1.61
--- pgsql/src/backend/commands/tablespace.c 17 Aug 2009 22:36:01
-0000
***************
*** 611,616 ****
--- 611,623 ----
errmsg("could not remove
directory \"%s\": %m",
subfile)));

+ /*
+ * The following two lines work around a bug in Mac OS
X Snow Leopard (Build 10A432)
+ * readdir() implementation. We free dirdesc and
reread location from start.
+ */
+ FreeDir(dirdesc);
+ dirdesc = AllocateDir(location);
+
pfree(subfile);
}

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-08-17 23:01:26 Re: [COMMITTERS] pgsql: Add release notes for 8.5alpha1
Previous Message Tom Lane 2009-08-17 22:55:52 Re: explain root element for auto-explain