Re: Why copy_relation_data only use wal when WALarchiving is enabled

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Jacky Leng <lengjianquan(at)163(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why copy_relation_data only use wal when WALarchiving is enabled
Date: 2007-10-17 11:14:54
Message-ID: 4715EEAE.6090105@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Forgot to attach the script I promised..

You need to set $PGDATA before running the script. And psql,pg_ctl and
pg_resetxlog need to be in $PATH. After running the script, restart
postmaster and run "SELECT * FROM t2". There should be one row in the
table, but it's empty.

Heikki Linnakangas wrote:
> Simon Riggs wrote:
>> On Wed, 2007-10-17 at 17:18 +0800, Jacky Leng wrote:
>>> Second, suppose that no checkpoint has occured during the upper
>>> series--authough not quite possible;
>> That part is irrelevant. It's forced out to disk and doesn't need
>> recovery, with or without the checkpoint.
>>
>> There's no hole that I can see.
>
> No, Jacky is right. The same problem exists at least with CLUSTER, and I
> think there's other commands that rely on immediate fsync as well.
>
> Attached is a shell script that demonstrates the problem on CVS HEAD
> with CLUSTER. It creates two tables, T1 and T2, both with one row. Then
> T1 is dropped, and T2 is CLUSTERed, so that the new T2 relation file
> happens to get the same relfilenode that T1 had. Then we crash the
> server, forcing a WAL replay. After that, T2 is empty. Oops.
>
> Unfortunately I don't see any easy way to fix it. One approach would be
> to avoid reusing the relfilenodes until next checkpoint, but I don't see
> any nice place to keep track of OIDs that have been dropped since last
> checkpoint.
>

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

Attachment Content-Type Size
cluster-relfilenode-clash.sh.gz application/x-gzip 517 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2007-10-17 11:38:23 Re: [RFC] extended txid docs
Previous Message Heikki Linnakangas 2007-10-17 11:11:03 Re: Why copy_relation_data only use wal when WALarchiving is enabled

Browse pgsql-patches by date

  From Date Subject
Next Message Marko Kreen 2007-10-17 11:38:23 Re: [RFC] extended txid docs
Previous Message Heikki Linnakangas 2007-10-17 11:11:03 Re: Why copy_relation_data only use wal when WALarchiving is enabled