Re: BackendKeyData is mandatory?

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, tgl(at)sss(dot)pgh(dot)pa(dot)us, peter(at)eisentraut(dot)org, pgsql-hackers(at)postgresql(dot)org, Dave Cramer <davecramer(at)gmail(dot)com>
Subject: Re: BackendKeyData is mandatory?
Date: 2025-08-07 22:02:56
Message-ID: 6c6958d0-e27b-4c63-9465-4b6f894d35ee@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

(reviewing patch 2 now)

On 03/07/2025 09:13, Jelte Fennema-Nio wrote:
> On Thu Jul 3, 2025 at 2:03 AM CEST, Jacob Champion wrote:
>> On Wed, Jul 2, 2025 at 3:18 PM Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
>> wrote:
>> I will hold off on detailed review until Heikki gives an opinion on
>> the design (or we get closer to the end of the month), to avoid making
>> busy work for you -- but I will say that I think you need to prove
>> that the new `failure:` case in getBackendKeyData() is safe, because I
>> don't think any of the other failure modes behave that way inside
>> pqParseInput3().
>
> I changed it slightly now to align with the handleSyncLoss function its
> implementation.

That seems good, except maybe the copy-pasted comments could be adjusted
a bit. But I wonder why you added this:

--- a/src/interfaces/libpq/fe-connect.c

+++ b/src/interfaces/libpq/fe-connect.c

@@ -4322,6 +4322,9 @@ keep_going:
\
/* We will come back to here until there is

if (PQisBusy(conn))

return PGRES_POLLING_READING;

+ if (conn->status == CONNECTION_BAD)

+ goto error_return;

+

res = PQgetResult(conn);

/*

That was not necessary for handleSyncLoss() to work, or for any other
errors. If an error has occurred, PQgetResult() returns an error result,
which is handled here.

It's not necessarily a bad idea. It saves some effort, as PQgetResult()
doesn't need to construct the result object, which we will just
immediately free again. But we have been doing fine without it.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2025-08-07 23:31:18 Re: event trigger support for PL/Python
Previous Message Masahiko Sawada 2025-08-07 21:59:36 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart