Re: WAL logging problem in 9.4.3? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: WAL logging problem in 9.4.3?
Date
Msg-id 20150703170229.GJ3291@awork2.anarazel.de
Whole thread Raw
In response to Re: WAL logging problem in 9.4.3?  (Andres Freund <andres@anarazel.de>)
Responses Re: WAL logging problem in 9.4.3?
List pgsql-hackers
On 2015-07-03 18:49:31 +0200, Andres Freund wrote:
> But the more interesting question is why that's not hhappening
> today. RelationTruncateIndexes() does call the index_build() which
> should end up WAL logging the index creation.

So that's because there's an XLogIsNeeded() preventing it.

Maybe I'm just daft right now (35C outside, 32 inside, so ...), but I'm
right now missing how the whole "skip wal logging if relation has just
been truncated" optimization can ever actually be crashsafe unless we
use a new relfilenode (which we don't!).

Sure, we do an heap_sync() at the the end of the transaction. That's
nice and all. But it doesn't help if we crash and re-start WAL apply
from a checkpoint before the table was created. Because that'll replay
the truncation.

That's much worse than just the indexes - the rows added by a COPY
without WAL logging will also be truncated away, no?



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Reducing the size of BufferTag & remodeling forks
Next
From: Noah Misch
Date:
Subject: Re: more RLS oversights