Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without

Lists: pgsql-committerspgsql-hackers
From: heikki(at)postgresql(dot)org (Heikki Linnakangas)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-01-20 19:43:40
Message-ID: 20100120194340.9B2097541B9@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Log Message:
-----------
Write a WAL record whenever we perform an operation without WAL-logging
that would've been WAL-logged if archiving was enabled. If we encounter
such records in archive recovery anyway, we know that some data is
missing from the log. A WARNING is emitted in that case.

Original patch by Fujii Masao, with changes by me.

Modified Files:
--------------
pgsql/src/backend/access/heap:
heapam.c (r1.282 -> r1.283)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/heapam.c?r1=1.282&r2=1.283)
pgsql/src/backend/access/nbtree:
nbtsort.c (r1.122 -> r1.123)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/nbtree/nbtsort.c?r1=1.122&r2=1.123)
pgsql/src/backend/access/transam:
xlog.c (r1.358 -> r1.359)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xlog.c?r1=1.358&r2=1.359)
pgsql/src/backend/commands:
cluster.c (r1.193 -> r1.194)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/cluster.c?r1=1.193&r2=1.194)
tablecmds.c (r1.316 -> r1.317)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.316&r2=1.317)
pgsql/src/include/access:
xlog.h (r1.97 -> r1.98)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/access/xlog.h?r1=1.97&r2=1.98)
pgsql/src/include/catalog:
pg_control.h (r1.48 -> r1.49)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_control.h?r1=1.48&r2=1.49)


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(at)postgresql(dot)org>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-01-21 03:40:05
Message-ID: 603c8f071001201940o3b3c5709hb6f222f38683541a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Wed, Jan 20, 2010 at 2:43 PM, Heikki Linnakangas
<heikki(at)postgresql(dot)org> wrote:
> Log Message:
> -----------
> Write a WAL record whenever we perform an operation without WAL-logging
> that would've been WAL-logged if archiving was enabled. If we encounter
> such records in archive recovery anyway, we know that some data is
> missing from the log. A WARNING is emitted in that case.
>
> Original patch by Fujii Masao, with changes by me.

Does this need to be updated, then?

https://commitfest.postgresql.org/action/patch_view?id=237

...Robert


From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Heikki Linnakangas <heikki(at)postgresql(dot)org>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-01-21 03:56:20
Message-ID: 20100121125620.D17B.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers


Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Does this need to be updated, then?
> https://commitfest.postgresql.org/action/patch_view?id=237

I updated it.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Heikki Linnakangas <heikki(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 08:40:57
Message-ID: 1265013657.13782.10934.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

I'm seeing these messages in the standby server log:

WARNING: unlogged operation performed, data may be missing
HINT: This can happen if you temporarily disable archive_mode without
taking a new base backup.
CONTEXT: xlog redo unlogged operation: heap inserts on "pg_temp_65646"

which connected with operations on temp tables, probably as a result of
VACUUM FULL and CLUSTER.

I don't think those messages should be there.

On Wed, 2010-01-20 at 19:43 +0000, Heikki Linnakangas wrote:
> Log Message:
> -----------
> Write a WAL record whenever we perform an operation without WAL-logging
> that would've been WAL-logged if archiving was enabled. If we encounter
> such records in archive recovery anyway, we know that some data is
> missing from the log. A WARNING is emitted in that case.
>
> Original patch by Fujii Masao, with changes by me.
>
> Modified Files:
> --------------
> pgsql/src/backend/access/heap:
> heapam.c (r1.282 -> r1.283)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/heapam.c?r1=1.282&r2=1.283)
> pgsql/src/backend/access/nbtree:
> nbtsort.c (r1.122 -> r1.123)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/nbtree/nbtsort.c?r1=1.122&r2=1.123)
> pgsql/src/backend/access/transam:
> xlog.c (r1.358 -> r1.359)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xlog.c?r1=1.358&r2=1.359)
> pgsql/src/backend/commands:
> cluster.c (r1.193 -> r1.194)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/cluster.c?r1=1.193&r2=1.194)
> tablecmds.c (r1.316 -> r1.317)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.316&r2=1.317)
> pgsql/src/include/access:
> xlog.h (r1.97 -> r1.98)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/access/xlog.h?r1=1.97&r2=1.98)
> pgsql/src/include/catalog:
> pg_control.h (r1.48 -> r1.49)
> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_control.h?r1=1.48&r2=1.49)
>
--
Simon Riggs www.2ndQuadrant.com


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 09:33:44
Message-ID: 4B669FF8.806@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Simon Riggs wrote:
> I'm seeing these messages in the standby server log:
>
> WARNING: unlogged operation performed, data may be missing
> HINT: This can happen if you temporarily disable archive_mode without
> taking a new base backup.
> CONTEXT: xlog redo unlogged operation: heap inserts on "pg_temp_65646"
>
> which connected with operations on temp tables, probably as a result of
> VACUUM FULL and CLUSTER.
>
> I don't think those messages should be there.

Hmm. The "unlogged" record is written here:

...
void
heap_sync(Relation rel)
{
char reason[NAMEDATALEN + 30];

/* temp tables never need fsync */
if (rel->rd_istemp)
return;

snprintf(reason, sizeof(reason), "heap inserts on \"%s\"",
RelationGetRelationName(rel));
XLogReportUnloggedStatement(reason);
...

So it clearly shouldn't be written for temp relations. Apparently the
rd_istemp flag not set correctly after CLUSTER / VACUUM FULL.

Can you reproduce that?

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


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 09:53:36
Message-ID: 1265018016.13782.11175.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
> Can you reproduce that?

Every time

--
Simon Riggs www.2ndQuadrant.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 09:58:00
Message-ID: 3f0b79eb1002010158m5ce05291i7bd619b5388923b4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, Feb 1, 2010 at 6:33 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Hmm. The "unlogged" record is written here:
>
> ...
> void
> heap_sync(Relation rel)
> {
>        char reason[NAMEDATALEN + 30];
>
>        /* temp tables never need fsync */
>        if (rel->rd_istemp)
>                return;
>
>        snprintf(reason, sizeof(reason), "heap inserts on \"%s\"",
>                         RelationGetRelationName(rel));
>        XLogReportUnloggedStatement(reason);
> ...
>
>
> So it clearly shouldn't be written for temp relations. Apparently the
> rd_istemp flag not set correctly after CLUSTER / VACUUM FULL.

The cause of the problem seems to be the new heap created by
rebuild_relation() and copy_heap_data(), i.e., new VACUUM FULL.
Since it's not a temporary heap, its rd_istemp is off. OTOH
it needs to be synced after physical copy from old heap. So
XLogReportUnloggedStatement() is called in heap_sync().

The easy fix is to change the code as below.

if (XLogIsNeeded())
{
snprintf(reason, sizeof(reason), "heap inserts on \"%s\"",
RelationGetRelationName(rel));
XLogReportUnloggedStatement(reason);
}

But I'm not sure this fix is right, so I need to investigate
the code more.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:11:56
Message-ID: 4B66A8EC.3090109@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Simon Riggs wrote:
> On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
>> Can you reproduce that?
>
> Every time

Ok, good :-). What I really meant was: How?

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


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:14:56
Message-ID: 1265019296.13782.11258.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, 2010-02-01 at 12:11 +0200, Heikki Linnakangas wrote:
> Simon Riggs wrote:
> > On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
> >> Can you reproduce that?
> >
> > Every time
>
> Ok, good :-). What I really meant was: How?

As mentioned in first post: VACUUM FULL and CLUSTER.

Coffee is recommended.

--
Simon Riggs www.2ndQuadrant.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:15:21
Message-ID: 3f0b79eb1002010215k4d02c11k9d6c9601f22b5762@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, Feb 1, 2010 at 6:58 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>    if (XLogIsNeeded())
>    {
>        snprintf(reason, sizeof(reason), "heap inserts on \"%s\"",
>                         RelationGetRelationName(rel));
>        XLogReportUnloggedStatement(reason);
>    }

Oops!
Typo: XLogIsNeeded() --> !XLogIsNeeded()

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:27:15
Message-ID: 4B66AC83.4070703@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Fujii Masao wrote:
> The cause of the problem seems to be the new heap created by
> rebuild_relation() and copy_heap_data(), i.e., new VACUUM FULL.
> Since it's not a temporary heap, its rd_istemp is off. OTOH
> it needs to be synced after physical copy from old heap.

Why does it need to be synced?

ISTM the bug is that rd_istemp is off at that point.

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


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:30:43
Message-ID: 4B66AD53.7030807@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Simon Riggs wrote:
> On Mon, 2010-02-01 at 12:11 +0200, Heikki Linnakangas wrote:
>> Simon Riggs wrote:
>>> On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
>>>> Can you reproduce that?
>>> Every time
>> Ok, good :-). What I really meant was: How?
>
> As mentioned in first post: VACUUM FULL and CLUSTER.

I'm asking because I couldn't reproduce it. I added an elog(LOG) to
XLogReportUnloggedStatement() so that I can see when an unlogged-record
is written. Then I ran:

CREATE TEMPORARY TABLE foo (id int4);
VACUUM FULL foo;

But XLogReportUnloggedStatement() was not executed. When I removed the
"TEMPORARY" and tried again, it was executed.

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


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:36:59
Message-ID: 3f0b79eb1002010236g68009c3dmdaf8c985bcbbbc56@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, Feb 1, 2010 at 7:27 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>> The cause of the problem seems to be the new heap created by
>> rebuild_relation() and copy_heap_data(), i.e., new VACUUM FULL.
>> Since it's not a temporary heap, its rd_istemp is off. OTOH
>> it needs to be synced after physical copy from old heap.
>
> Why does it need to be synced?
>
> ISTM the bug is that rd_istemp is off at that point.

Umm... ISTM that new heap needs to be synced before calling
swap_relation_files(), but, in the now, I'm not sure whether
it's really required or not. Sorry.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:38:44
Message-ID: 3f0b79eb1002010238u5866d8c9w5f0e7abc855a8c4b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, Feb 1, 2010 at 7:30 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> CREATE TEMPORARY TABLE foo (id int4);
> VACUUM FULL foo;

How about issuing just "VACUUM FULL" after creating log-shipping environment?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:40:51
Message-ID: 4B66AFB3.6040709@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Heikki Linnakangas wrote:
> Simon Riggs wrote:
>> On Mon, 2010-02-01 at 12:11 +0200, Heikki Linnakangas wrote:
>>> Simon Riggs wrote:
>>>> On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
>>>>> Can you reproduce that?
>>>> Every time
>>> Ok, good :-). What I really meant was: How?
>> As mentioned in first post: VACUUM FULL and CLUSTER.
>
> I'm asking because I couldn't reproduce it. I added an elog(LOG) to
> XLogReportUnloggedStatement() so that I can see when an unlogged-record
> is written. Then I ran:
>
> CREATE TEMPORARY TABLE foo (id int4);
> VACUUM FULL foo;
>
> But XLogReportUnloggedStatement() was not executed. When I removed the
> "TEMPORARY" and tried again, it was executed.

No, hang on. When I run this:

postgres=# CREATE TABLE foo (id int4);
CREATE TABLE
postgres=# vacuum full foo;
VACUUM

I get this in the log:

LOG: Writing record: CLUSTER on "pg_temp_24677"
STATEMENT: vacuum full foo;
LOG: Writing record: heap inserts on "pg_temp_24677"
STATEMENT: vacuum full foo;

So you get those messages when the table is *not* a temporary table. I
can see now what Fujii was trying to say. His patch seems Ok, though
perhaps it would be better to move the responsibility of calling
XLogReportUnloggedStatement() to the callers of heap_sync(). When I put
it in heap_sync(), I didn't take into account that it's sometimes called
just to flush buffers from buffer cache, not to fsync() non-WAL-logged
operations.

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


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 10:46:06
Message-ID: 1265021166.13782.11353.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, 2010-02-01 at 12:30 +0200, Heikki Linnakangas wrote:
> Simon Riggs wrote:
> > On Mon, 2010-02-01 at 12:11 +0200, Heikki Linnakangas wrote:
> >> Simon Riggs wrote:
> >>> On Mon, 2010-02-01 at 11:33 +0200, Heikki Linnakangas wrote:
> >>>> Can you reproduce that?
> >>> Every time
> >> Ok, good :-). What I really meant was: How?
> >
> > As mentioned in first post: VACUUM FULL and CLUSTER.
>
> I'm asking because I couldn't reproduce it. I added an elog(LOG) to
> XLogReportUnloggedStatement() so that I can see when an unlogged-record
> is written. Then I ran:
>
> CREATE TEMPORARY TABLE foo (id int4);
> VACUUM FULL foo;
>
> But XLogReportUnloggedStatement() was not executed. When I removed the
> "TEMPORARY" and tried again, it was executed.

drop table if exists foo;
create table foo (col1 serial, col2 text);
insert into foo (col2)
select repeat('a', 5000) from generate_series(1,1000);
create index on foo (col1);
cluster foo using foo_col1_idx;

So it appears this relates to toast tables.

--
Simon Riggs www.2ndQuadrant.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-01 16:13:50
Message-ID: 20935.1265040830@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> On Mon, Feb 1, 2010 at 7:27 PM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> Fujii Masao wrote:
>>> The cause of the problem seems to be the new heap created by
>>> rebuild_relation() and copy_heap_data(), i.e., new VACUUM FULL.
>>> Since it's not a temporary heap, its rd_istemp is off. OTOH
>>> it needs to be synced after physical copy from old heap.
>>
>> Why does it need to be synced?
>>
>> ISTM the bug is that rd_istemp is off at that point.

> Umm... ISTM that new heap needs to be synced before calling
> swap_relation_files(), but, in the now, I'm not sure whether
> it's really required or not. Sorry.

If the original table is temp, then none of this work needs to be
fsync'd. Ever. So ISTM that CLUSTER ought to be copying the istemp
bit. Another reason to do that is to make sure that the new instance
of the table goes into the temp tablespace and not the regular one.

regards, tom lane


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-02 04:40:14
Message-ID: 3f0b79eb1002012040r777313bcv4d3b13c72cecc0d8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Mon, Feb 1, 2010 at 7:40 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> So you get those messages when the table is *not* a temporary table. I
> can see now what Fujii was trying to say. His patch seems Ok, though
> perhaps it would be better to move the responsibility of calling
> XLogReportUnloggedStatement() to the callers of heap_sync(). When I put
> it in heap_sync(), I didn't take into account that it's sometimes called
> just to flush buffers from buffer cache, not to fsync() non-WAL-logged
> operations.

As you said, I moved the responsibility of calling XLogReportUnloggedStatement()
to the callers of heap_sync(). Here is the patch.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
unlogged_operation_by_vacuum_full_20100202.patch text/x-patch 4.7 KB

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-03 10:03:00
Message-ID: 4B6949D4.4010703@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Fujii Masao wrote:
> On Mon, Feb 1, 2010 at 7:40 PM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> So you get those messages when the table is *not* a temporary table. I
>> can see now what Fujii was trying to say. His patch seems Ok, though
>> perhaps it would be better to move the responsibility of calling
>> XLogReportUnloggedStatement() to the callers of heap_sync(). When I put
>> it in heap_sync(), I didn't take into account that it's sometimes called
>> just to flush buffers from buffer cache, not to fsync() non-WAL-logged
>> operations.
>
> As you said, I moved the responsibility of calling XLogReportUnloggedStatement()
> to the callers of heap_sync(). Here is the patch.

Committed. The use_wal parameter to end_heap_rewrite() was not
necessary, that information is already in RewriteState, so I took that out.

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


From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: heikki(dot)linnakangas(at)enterprisedb(dot)com
Cc: masao(dot)fujii(at)gmail(dot)com, simon(at)2ndquadrant(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-03 10:19:19
Message-ID: 20100203.191919.64297734.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

> Fujii Masao wrote:
> > On Mon, Feb 1, 2010 at 7:40 PM, Heikki Linnakangas
> > <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> >> So you get those messages when the table is *not* a temporary table. I
> >> can see now what Fujii was trying to say. His patch seems Ok, though
> >> perhaps it would be better to move the responsibility of calling
> >> XLogReportUnloggedStatement() to the callers of heap_sync(). When I put
> >> it in heap_sync(), I didn't take into account that it's sometimes called
> >> just to flush buffers from buffer cache, not to fsync() non-WAL-logged
> >> operations.
> >
> > As you said, I moved the responsibility of calling XLogReportUnloggedStatement()
> > to the callers of heap_sync(). Here is the patch.
>
> Committed. The use_wal parameter to end_heap_rewrite() was not
> necessary, that information is already in RewriteState, so I took that out.

Are we going to bump up frontend/backend protocol version 3.0 to 3.x
or some such?
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: masao(dot)fujii(at)gmail(dot)com, simon(at)2ndquadrant(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Write a WAL record whenever we perform an operation without
Date: 2010-02-03 10:50:06
Message-ID: 4B6954DE.5010500@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Tatsuo Ishii wrote:
>> Fujii Masao wrote:
>>> On Mon, Feb 1, 2010 at 7:40 PM, Heikki Linnakangas
>>> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>>>> So you get those messages when the table is *not* a temporary table. I
>>>> can see now what Fujii was trying to say. His patch seems Ok, though
>>>> perhaps it would be better to move the responsibility of calling
>>>> XLogReportUnloggedStatement() to the callers of heap_sync(). When I put
>>>> it in heap_sync(), I didn't take into account that it's sometimes called
>>>> just to flush buffers from buffer cache, not to fsync() non-WAL-logged
>>>> operations.
>>> As you said, I moved the responsibility of calling XLogReportUnloggedStatement()
>>> to the callers of heap_sync(). Here is the patch.
>> Committed. The use_wal parameter to end_heap_rewrite() was not
>> necessary, that information is already in RewriteState, so I took that out.
>
> Are we going to bump up frontend/backend protocol version 3.0 to 3.x
> or some such?

No, this doesn't affect the normal FE/BE protocol. The message header
was added to the streaming replication messages that are sent within
CopyData messages.

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