The following bug has been logged online:
Bug reference: 3143
Logged by: Chongfeng Hu
Email address: loveminix@yahoo.com.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.