Re: RecoveryInProgress() has critical side effects

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, amul sul <sulamul(at)gmail(dot)com>
Subject: Re: RecoveryInProgress() has critical side effects
Date: 2021-11-15 21:29:28
Message-ID: CA+TgmoZOfaQ1-s+pL3Nx4UDwL1jm496gCRzfFJZV01==eq3DMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 12, 2021 at 10:23 AM Bossart, Nathan <bossartn(at)amazon(dot)com> wrote:
> 0001 looks reasonable to me.

Cool.

> Unless there's a demonstrable performance benefit from adding the
> branch, my preference is to leave it out. I could be off-base, but it
> seems possible that future changes might end up depending on any side
> effects from this new branch, which is exactly what you're trying to
> fix. Plus, always using the retry path is a good way to test that it
> works as expected.

Here's a new version that does it that way. Any other opinions?

The best thing I could come up with for a test case for this was to
try repeatedly making a new connection and running "SELECT
txid_current()", which will cause just one WAL record to be generated.
Unfortunately that path has overhead from a lot of other causes so I'm
not sure the results are very meaningful, but here they are:

v1: 0.378 ms
v2: 0.391 ms
common base commit (10eae82b2): 0.376 ms

methodology:
for i in `seq 1 1000`; do psql -c '\timing' -c 'select
txid_current();'; done | grep '^Time:' | awk '{total+=$2} END {print
total/NR}'
run twice, discarding the first result, since the very first
connection attempt after starting a new server process is notably
slower

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

Attachment Content-Type Size
v2-0002-Remove-InitXLOGAccess.patch application/octet-stream 7.7 KB
v2-0001-Move-InitXLogInsert-call-from-InitXLOGAccess-to-B.patch application/octet-stream 2.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2021-11-15 21:36:05 Re: Logical Replication - improve error message while adding tables to the publication in check_publication_add_relation
Previous Message Tom Lane 2021-11-15 21:12:12 Re: Time to drop plpython2?