BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?

From: "Chongfeng Hu" <loveminix(at)yahoo(dot)com(dot)cn>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?
Date: 2007-03-12 03:00:21
Message-ID: 200703120300.l2C30LU2045849@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3143
Logged by: Chongfeng Hu
Email address: loveminix(at)yahoo(dot)com(dot)cn
PostgreSQL version: 8.2.3
Operating system: any
Description: MyLastRecPtr.xlogid not updated with
MyLastRecPtr.xrecoff?
Details:

I checked the source of PostgreSQL, and found one suspicious spot in file
src/backend/access/transam/xact.c. In struct XLogRecPtr, it has two fields:
xlogid, indicating log file #, and xrecoff, indicating the byte offset of
location in log file, so they should always keep consistent, as I saw in
many places, just list one of them:

if (tmpRecPtr.xrecoff >= XLogFileSize)
{
(tmpRecPtr.xlogid)++;
tmpRecPtr.xrecoff = 0;
}

However, in file src/backend/access/transam/xact.c, on line 1778, I saw the
following code:

/* Break the chain of back-links in the XLOG records I output */
MyLastRecPtr.xrecoff = 0;
MyXactMadeXLogEntry = false;
MyXactMadeTempRelUpdate = false;

It only updated xrecoff, but not xlogid. This might cause serious problems,
because xlogid is still pointing to an old file, while xrecoff is pointing
to a new offset. It might read incorrect records.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2007-03-12 13:06:57 Re: BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?
Previous Message Tom Lane 2007-03-10 23:02:12 Re: BUG #3110: Online Backup introduces Duplicate OIDs