Re: possible bug: orphaned files left after immediate shutdown during DDL

Lists: pgsql-bugs
From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: possible bug: orphaned files left after immediate shutdown during DDL
Date: 2011-02-10 03:37:06
Message-ID: 1297309026.11375.7.camel@jdavis-ux.asterdata.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Case:

BEGIN;
CREATE TABLE foo AS SELECT generate_series(1,1000);
CHECKPOINT;
SELECT relfilenode FROM pg_class WHERE relname='foo';

Let's say that returns 23456. Send the postmaster a SIGQUIT (immediate
shutdown), and then restart. The file 23456 is still in the filesystem,
but there's no record in pg_class for it. I don't see any obvious path
where it will be removed, so it looks like it will just stay there
forever.

My question is: is this a conscious decision to be paranoid during
recovery, or is this a bug? Or is there some reason that properly
determining which files should be removed at recovery time is
challenging?

Regards,
Jeff Davis


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: possible bug: orphaned files left after immediate shutdown during DDL
Date: 2011-02-10 03:58:46
Message-ID: 20348.1297310326@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> Case:

> BEGIN;
> CREATE TABLE foo AS SELECT generate_series(1,1000);
> CHECKPOINT;
> SELECT relfilenode FROM pg_class WHERE relname='foo';

> Let's say that returns 23456. Send the postmaster a SIGQUIT (immediate
> shutdown), and then restart. The file 23456 is still in the filesystem,
> but there's no record in pg_class for it. I don't see any obvious path
> where it will be removed, so it looks like it will just stay there
> forever.

> My question is: is this a conscious decision to be paranoid during
> recovery, or is this a bug?

It's intentional ... not that other people haven't complained about it
before. Remember that what you have done is forced a crash, and
recovery from it is crash recovery. If we proactively removed such
files we would very possibly be destroying evidence of forensic value.

IMO, immediate shutdown is not a tool to be used at random, and this
isn't something we need to fix.

regards, tom lane


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: possible bug: orphaned files left after immediate shutdown during DDL
Date: 2011-02-10 04:14:07
Message-ID: 1297311247.27157.486.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, 2011-02-09 at 22:58 -0500, Tom Lane wrote:
> It's intentional ... not that other people haven't complained about it
> before. Remember that what you have done is forced a crash, and
> recovery from it is crash recovery. If we proactively removed such
> files we would very possibly be destroying evidence of forensic value.

I thought that might be the case, but I wasn't able to find any previous
discussions.

It might be a good idea to issue a warning during recovery, however,
like "possible orphaned file ...". I'm not sure if it's worth the
bookkeeping effort though.

Regards,
Jeff Davis


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: possible bug: orphaned files left after immediate shutdown during DDL
Date: 2011-02-16 13:45:50
Message-ID: 201102161345.p1GDjoO22162@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Jeff Davis wrote:
> On Wed, 2011-02-09 at 22:58 -0500, Tom Lane wrote:
> > It's intentional ... not that other people haven't complained about it
> > before. Remember that what you have done is forced a crash, and
> > recovery from it is crash recovery. If we proactively removed such
> > files we would very possibly be destroying evidence of forensic value.
>
> I thought that might be the case, but I wasn't able to find any previous
> discussions.
>
> It might be a good idea to issue a warning during recovery, however,
> like "possible orphaned file ...". I'm not sure if it's worth the
> bookkeeping effort though.

I thought we had a TODO item about removing orphaned files, but I don't
see it now, perhaps because I thought we had fixed that.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +