Re: New VACUUM FULL crashes on temp relations

Lists: pgsql-hackers
From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: New VACUUM FULL crashes on temp relations
Date: 2010-02-01 08:29:40
Message-ID: 1265012980.13782.10883.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


TRAP: FailedAssertion("!(typeNamespace == typ->typnamespace)", File:
"pg_type.c", Line: 658)

Test case attached, repeated, consistent failure on CVS HEAD.

Crash occurs with either CLUSTER or VACUUM FULL.

Passed on without further investigation.

--
Simon Riggs www.2ndQuadrant.com

Attachment Content-Type Size
vftest.sql text/x-sql 1.1 KB

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: New VACUUM FULL crashes on temp relations
Date: 2010-02-02 00:45:19
Message-ID: 20100202094519.9A64.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:

> TRAP: FailedAssertion("!(typeNamespace == typ->typnamespace)", File:
> "pg_type.c", Line: 658)
>
> Test case attached, repeated, consistent failure on CVS HEAD.

I see the same assertion failure on 8.4.2, too.
I'll investigating it...

-- minimum reproducible pattern
drop table if exists footemp;
create temp table footemp (col1 serial, col2 text);
create index footemp_col1_idx on footemp (col1);
cluster footemp using footemp_col1_idx;

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


From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New VACUUM FULL crashes on temp relations
Date: 2010-02-02 05:28:32
Message-ID: 20100202142831.9A8A.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> wrote:

> > TRAP: FailedAssertion("!(typeNamespace == typ->typnamespace)", File:
> > "pg_type.c", Line: 658)

It comes from swapping toast relations:
DEBUG: typeNamespace mismatch: 99 (pg_toast) vs. 16386 (pg_toast_temp_2)

AFAICS, the assertion is broken, but the code is correct. We just need to
adjust the expression in the assertion.
Patch attached, including new regression tests for clustering a temp table.

> I see the same assertion failure on 8.4.2, too.

I'll go for backpatcting if the attached fix is correct. Comments welcome.

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

Attachment Content-Type Size
cluster_assert_20100202.patch application/octet-stream 2.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New VACUUM FULL crashes on temp relations
Date: 2010-02-02 16:57:14
Message-ID: 8132.1265129834@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> AFAICS, the assertion is broken, but the code is correct. We just need to
> adjust the expression in the assertion.

I think this is 100% wrong. Toast tables shouldn't be changing
namespace either; which means you broke something somewhere else.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New VACUUM FULL crashes on temp relations
Date: 2010-02-02 18:55:31
Message-ID: 27507.1265136931@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
>> AFAICS, the assertion is broken, but the code is correct. We just need to
>> adjust the expression in the assertion.

> I think this is 100% wrong. Toast tables shouldn't be changing
> namespace either; which means you broke something somewhere else.

After tracing through it, the problem is that rebuild_relation() assumes
toast tables are always in PG_TOAST_NAMESPACE; which has not been true
since 8.3. CLUSTER has been renaming temp toast tables into the wrong
namespace right along. Without the assert to call attention to it, who
knows how long it would've taken to notice :-(

Will fix.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New VACUUM FULL crashes on temp relations
Date: 2010-02-02 19:16:17
Message-ID: 28798.1265138177@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> After tracing through it, the problem is that rebuild_relation() assumes
> toast tables are always in PG_TOAST_NAMESPACE; which has not been true
> since 8.3. CLUSTER has been renaming temp toast tables into the wrong
> namespace right along. Without the assert to call attention to it, who
> knows how long it would've taken to notice :-(

No, on closer inspection the bug was introduced here:
http://archives.postgresql.org/pgsql-committers/2008-10/msg00118.php
so 8.3 was OK. In a non-asserting build the only consequence would have
been that checks for conflicting names were done in the wrong namespace.
Given the improbability of a conflict, we could have gone a very long
time before noticing the problem. But it was still wrong.

regards, tom lane