Question about pg_control usage

Started by Anastasia Lubennikovaover 9 years ago3 messages
#1Anastasia Lubennikova
a.lubennikova@postgrespro.ru

Hi, hackers!

I am examining various global variables in ShmemVariableCache,
pg_control and pg_controldata. To force and debug xid wraparound,
I've implemented a function, that allows to set nextXid value in control
file manually, but it doesn't work as expected.

After an investigation I found that, while loading global variables in
StartupXlog()
we read checkPoint location from ControlFile, and then read all the
information
from the checkPoint record. And never ever use nextXid stored in
ControlFile.

What is the purpose of having CheckPoint stored in control file then?
I thought, that it allows us to start up server after correct shutdown
without any xlog, as said in the comment in pg_control.h

* Body of CheckPoint XLOG records. This is declared here because we keep
* a copy of the latest one in pg_control for possible disaster recovery.
* Changing this struct requires a PG_CONTROL_VERSION bump.

But as far as I see, we never use this data.

Could you please explain, why don't we use information from control file
in StartapXlog()?

--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Anastasia Lubennikova (#1)
Re: Question about pg_control usage

Anastasia Lubennikova <a.lubennikova@postgrespro.ru> writes:

What is the purpose of having CheckPoint stored in control file then?

IIRC, we use some but not all of the fields. It seemed prudent (and
simpler) to keep a copy of the whole thing.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Jeff Janes
jeff.janes@gmail.com
In reply to: Anastasia Lubennikova (#1)
Re: Question about pg_control usage

On Fri, Oct 7, 2016 at 8:24 AM, Anastasia Lubennikova <
a.lubennikova@postgrespro.ru> wrote:

Hi, hackers!

I am examining various global variables in ShmemVariableCache,
pg_control and pg_controldata. To force and debug xid wraparound,
I've implemented a function, that allows to set nextXid value in control
file manually, but it doesn't work as expected.

Why not use pg_resetxlog -x ?

After an investigation I found that, while loading global variables in

StartupXlog()
we read checkPoint location from ControlFile, and then read all the
information
from the checkPoint record. And never ever use nextXid stored in
ControlFile.

What is the purpose of having CheckPoint stored in control file then?
I thought, that it allows us to start up server after correct shutdown
without any xlog, as said in the comment in pg_control.h

* Body of CheckPoint XLOG records. This is declared here because we keep
* a copy of the latest one in pg_control for possible disaster recovery.
* Changing this struct requires a PG_CONTROL_VERSION bump.

But as far as I see, we never use this data.

Could you please explain, why don't we use information from control file
in StartapXlog()?

I believe pg_resetxlog uses the data from the control file to create an
artificial checkpoint record, and injects that record into an artificial
xlog file, which will allow you start the system. So it is a small use,
but a sometimes very important one.

Cheers,

Jeff