Re: cleaning up a few CLOG-related things - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: cleaning up a few CLOG-related things
Date
Msg-id 20009f3a-9189-7b3b-c9ed-764c1471642c@iki.fi
Whole thread Raw
In response to cleaning up a few CLOG-related things  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: cleaning up a few CLOG-related things  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 25/01/2021 18:56, Robert Haas wrote:
> I attach a series of proposed patches to slightly improve some minor
> things related to the CLOG code.
> 
> [patches 0001 - 0003]

Makes sense.

> 0004 - In StartupCLOG(), correct an off-by-one error. Currently, if
> the nextXid is exactly a multiple of the number of CLOG entries that
> fit on a page, then the value we compute for
> XactCtl->shared->latest_page_number is higher than it should be by 1.
> That's because nextXid represents the first XID that hasn't yet been
> allocated, not the last one that gets allocated.

Yes.

> So, the CLOG page gets created when nextXid advances from the first
> value on the page to the second value on the page, not when it
> advances from the last value on the previous page to the first value
> on the current page.
Yes. It took me a moment to understand that explanation, though. I'd 
phrase it something like "nextXid is the next XID that will be used, but 
we want to set latest_page_number according to the last XID that's 
already been used. So retreat by one."

Having a separate FullTransactionIdToLatestPageNumber() function for 
this seems like overkill to me.

> Some of the other SLRUs have similar issues as a result of
> copy-and-paste work over the years. I plan to look at tidying that
> stuff up, too. However, I wanted to post (and probably commit) these
> patches first, partly to get some feedback, and also because all the
> cases are a little different and I want to make sure to do a proper
> analysis of each one.

Yeah, multixact seems similar at least.

- Heikki



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Next
From: Anastasia Lubennikova
Date:
Subject: Re: pg_upgrade fails with non-standard ACL