Re: Latest version of Hot Standby patch: unexpected error querying standby

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>

From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Mark Kirkwood <markir@paradise.net.nz>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2009-01-04T14:38:08Z
Lists: pgsql-hackers
Simon Riggs wrote:
> On Sun, 2009-01-04 at 22:18 +1300, Mark Kirkwood wrote:
>>>>> bench=# select now(),count(*) from history;
>>>>> ERROR:  could not open relation base/16384/16394: No such file or
>>>>> directory
>>>>>     
> 
>> I'm guessing something tied up with the fact that history has no rows
>> to 
>> start with...
> 
> Good guess, thanks. I can recreate the error now, though not by
> following the actions in the order you mentioned. I guess the files
> hadn't applied fully before you ran the test.
> 
> The problem I can re-create looks like this:
> 
> 1. Create standby set-up, with both primary and standby active
> 2. Create new table on primary, but don't add data; wait for apply
> 3. Attempt to access new table on standby, throws ERROR as shown
> 4. Add 1 row on primary; wait for apply
> 5. Attempt to access new table on standby, no ERROR
> 
> It looks to me like WAL for CREATE TABLE doesn't actually create a file,
> we just rely on the ability of mdextend() to create the file if required
> during recovery.
> 
> So it looks to me like either an outstanding error with current system,
> or a new error introduced with recent-ish md/smgr changes. Second
> opinion please Heikki, if you are available?

Hmm, that's odd. Table creation calls RelationCreateStorage, which calls 
smgrcreate and writes the WAL record. smgr_redo certainly does call 
smgrcreate.

I can reproduce that too with CVS HEAD, so it's clearly a bug. I 
probably introduced it with the recent smgr changes; I'll try to hunt it 
down.

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