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

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Chongfeng Hu <loveminix(at)yahoo(dot)com(dot)cn>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?
Date: 2007-03-12 13:06:57
Message-ID: 45F55071.2040906@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Chongfeng Hu wrote:
> 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.

No, that's actually ok. MyLastRecPtr is used to check if the current
transaction has made any transaction-controlled WAL records. If
MyLastRecPtr.xrecoff == 0, it hasn't, otherwise it has. All readers of
the variable just check for MyLastRecPtr.xrecoff == 0, so the above is OK.

I agree that it is a bit misleading, though. A boolean
"MyXactMadeTransactionControlledXlogEntry", like the
"MyXactMadeXLogEntry" and "MyXactMadeTempRelupdate" variables would be
cleaner.

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2007-03-12 14:21:39 Re: BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?
Previous Message Chongfeng Hu 2007-03-12 03:00:21 BUG #3143: MyLastRecPtr.xlogid not updated with MyLastRecPtr.xrecoff?