New function(s) to get various timelines that the postgres server deals with. - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject New function(s) to get various timelines that the postgres server deals with.
Date
Msg-id CALj2ACXTed9-OhGhaEQqkwpepuHQ0+F9kU5pXz7OeOS1pyST5A@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi,

I see there's no single function one can rely on to get various
timeline IDs [1] the postgres server deals with. We have the following
functions that emit controlfile's timelines
pg_control_checkpoint() - returns
ControlFile->checkPointCopy.ThisTimeLineID and
ControlFile->checkPointCopy.PrevTimeLineID
pg_control_recovery() - returns ControlFile->minRecoveryPointTLI

Most of the times XLogCtl->{InsertTimeLineID, PrevTimeLineID} and
ControlFile->checkPointCopy.{ThisTimeLineID, PrevTimeLineID} may be
the same (?).

No functions emit XLogRecoveryCtl->{lastReplayedTLI, replayEndTLI} and
WalRcv->{receiveStartTLI, receivedTLI}.

We may think of letting pg_current_wal_XXX, pg_last_wal_replay_lsn and
pg_last_wal_receive_lsn to return  XLogCtl->{InsertTimeLineID,
PrevTimeLineID}, XLogRecoveryCtl->{lastReplayedTLI, replayEndTLI} and
WalRcv->{receiveStartTLI, receivedTLI} respectively, but the names of
those functions need a change which I don't think is a great idea
given the fact that many client apps, control planes would have used
them.

We have two options:
1) Having a new set of functions, something like pg_current_wal_tli,
pg_last_wal_replay_tli and pg_last_wal_receive_tli.
2) A single function, something like pg_get_server_tlis or
pg_get_wal_timelines or some other.

I prefer option (1).

Thoughts?

[1]
XLogCtl->InsertTimeLineID
XLogCtl->PrevTimeLineID

XLogRecoveryCtl->lastReplayedTLI
XLogRecoveryCtl->replayEndTLI

WalRcv->receiveStartTLI
WalRcv->receivedTLI

ControlFile->checkPointCopy.ThisTimeLineID
ControlFile->checkPointCopy.PrevTimeLineID
ControlFile->minRecoveryPointTLI

Regards,
Bharath Rupireddy.



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Window Function "Run Conditions"
Next
From: chap@anastigmatix.net
Date:
Subject: Re: trigger example for plsample