Re: removing global variable ThisTimeLineID

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: removing global variable ThisTimeLineID
Date: 2021-11-08 17:49:52
Message-ID: CA+TgmoY1a2d1AnVR3tJcKmGGkhj7GGrwiNwjtKr21dxOuLBzCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 8, 2021 at 8:27 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Perhaps. That's related to the point I made before, that it might be a
> good idea to be more clear about which of these functions are intended
> to be used in recovery and which ones are intended to be used in
> normal running. I don't rule out the possibility of doing some more
> research here and tightening that up, but I don't want to go start
> tweaking things unless I'm sure I know what I'm talking about. This
> stuff is so confusing that I don't want to take any risk of making
> changes that turn out to be incorrect.

Well I went through and it seems to be OK: all the existing callers of
that function first verify that we're not in recovery. The patch to
make logical decoding work in standby mode might change that, but as
of now it's so. So in the attached patch, I have added the assertion
and comments that you have proposed there. I also removed the
misleading comment we discussed before. In addition to that, I renamed
the local variable ThisTimeLineID to replayTLI, and I also renamed
XLogCtl->ThisTimeLineID to InsertTimeLineID, which I think should make
things clearer: imagine if things that were used for different
purposes had different names!

Even with this patch, the name ThisTimeLineID is still used for
multiple purposes. It remains part of the CheckPoint struct, and also
part of the xl_end_of_recovery struct. But in both of those cases, the
name ThisTimeLineID actually makes sense, because what we're thinking
about is whether there's a timeline change, so we have ThisTimeLineID
and PrevTimeLineID and it seems fairly clear what that's supposed to
mean.

Thoughts?

--
Robert Haas
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
0001-More-cleanup-of-ThisTimeLineID.patch application/octet-stream 15.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2021-11-08 17:53:44 Re: Predefined role pg_maintenance for VACUUM, ANALYZE, CHECKPOINT.
Previous Message Stephen Frost 2021-11-08 17:47:23 Re: Predefined role pg_maintenance for VACUUM, ANALYZE, CHECKPOINT.