Re: DROP DATABASE vs patch to not remove files right away

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: DROP DATABASE vs patch to not remove files right away
Date: 2008-04-16 19:59:01
Message-ID: 48065A85.1030103@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Actually ... what if the same DB OID and relfilenode get re-made before
> the checkpoint? Then we'd be unlinking live data. This is improbable
> but hardly less so than the scenario the PendingUnlinkEntry code was
> put in to prevent.
>
> ISTM that we must fix the bgwriter so that ForgetDatabaseFsyncRequests
> causes PendingUnlinkEntrys for the doomed DB to be thrown away too.

Because of the asynchronous nature of ForgetDatabaseFsyncRequests, this
still isn't enough, I'm afraid.

1. DROP TABLE footable;
2. Checkpoint begins.
3. DROP DATABASE foodb;
4. CREATE DATABASE bardb; -- bardb gets same OID as foodb, and a table
copied from template database, let's call it bartable, gets same OID as
footable
5. Checkpoint processes pending unlink for footable, but removes
bartable instead

Needs more thought, after some sleep...

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2008-04-16 20:03:03 Re: How to submit a patch
Previous Message Brendan Jurd 2008-04-16 19:47:44 Re: How to submit a patch