Re: Index corruption - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: Index corruption |
Date | |
Msg-id | 18976.1151632037@sss.pgh.pa.us Whole thread Raw |
In response to | Index corruption (Marc Munro <marc@bloodnok.com>) |
Responses |
Re: Index corruption
Re: Index corruption |
List | pgsql-hackers |
Marc Munro <marc@bloodnok.com> writes: > If there's anything we can do to help debug this we will. We can apply > patches, different build options, etc. One easy thing that would be worth trying is to build with --enable-cassert and see if any Asserts get provoked during the failure case. I don't have a lot of hope for that, but it's something that would require only machine time not people time. A couple other things to try, given that you can provoke the failure fairly easily: 1. In studying the code, it bothers me a bit that P_NEW is the same as InvalidBlockNumber. The intended uses of P_NEW appear to be adequately interlocked, but it's fairly easy to see how something like this could happen if there are any places where InvalidBlockNumber is unintentionally passed to ReadBuffer --- that would look like a P_NEW call and it *wouldn't* be interlocked. So it would be worth changing P_NEW to "(-2)" (this should just take a change in bufmgr.h and recompile) and adding an "Assert(blockNum != InvalidBlockNumber)" at the head of ReadBufferInternal(). Then rebuild with asserts enabled and see if the failure case provokes that assert. 2. I'm also eyeing this bit of code in hio.c: /* * If the FSM knows nothing of the rel, try the last page before * we give up and extend. This avoidsone-tuple-per-page syndrome * during bootstrapping or in a recently-started system. */ if (targetBlock== InvalidBlockNumber) { BlockNumber nblocks = RelationGetNumberOfBlocks(relation); if (nblocks > 0) targetBlock = nblocks - 1; } If someone else has just extended the relation, it's possible that this will allow a process to get to the page before the intended extender has finished initializing it. AFAICT that's not harmful because the page will look like it has no free space ... but it seems a bit fragile. If you dike out the above-mentioned code, can you still provoke the failure? A different line of attack is to see if you can make a self-contained test case so other people can try to reproduce it. More eyeballs on the problem are always better. Lastly, it might be interesting to look at the WAL logs for the period leading up to a failure. This would give us an idea of what was happening concurrently with the processes that seem directly involved. regards, tom lane
pgsql-hackers by date: