public inbox for [email protected]  
help / color / mirror / Atom feed
Unexpected Backend PID reported by Notification
3+ messages / 2 participants
[nested] [flat]

* Unexpected Backend PID reported by Notification
@ 2024-06-11 15:05  Dominique Devienne <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Dominique Devienne @ 2024-06-11 15:05 UTC (permalink / raw)
  To: [email protected]

Hi. I have a unit test using a single connection, that simulates a
client interacting with a server via a PostgreSQL "queue", i.e. a
non-writable table with SECURITY DEFINER procedures to mediate writes
to that table, with those PROC-initiated updates triggering
pg_notify() messages (via an UPDATE trigger).

The test is passing, I get all the side-effects and notifications I
expect. BUT...
For some reason, the backend_pid reported on the notification object
itself (i.e. PGnotify::be_pid),
is different from the one reported for the (sole) connection the unit
test is using (PQbackendPID()).

How can that be?
Are Stored PROCs running in a different backend?
Are Triggers running in a different backend?

Any doc pointers to explain this behavior?

Thanks. --DD

PS: v14 server on RedHat; v16 libpq on Windows
PPS: Below's a snippet of my test code, which shows actual PID values:

    auto perreq_notif = c.notification();
    BOOST_REQUIRE(perreq_notif);
    BOOST_CHECK_EQUAL(perreq_notif.channel(), req.channel());
    /*
    ** In fact I get perreq_notif.backend_pid() == N + c.backend_pid() !!!
    ** Is the fact the pg_notify() is done from a trigger the reason???
    ** e.g. [4053957 != 4053955]
    BOOST_CHECK_EQUAL(perreq_notif.backend_pid(), c.backend_pid());
    */
    BOOST_CHECK_EQUAL(perreq_notif.payload(), "...");






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unexpected Backend PID reported by Notification
@ 2024-06-11 15:29  David G. Johnston <[email protected]>
  parent: Dominique Devienne <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: David G. Johnston @ 2024-06-11 15:29 UTC (permalink / raw)
  To: Dominique Devienne <[email protected]>; +Cc: [email protected] <[email protected]>

On Tuesday, June 11, 2024, Dominique Devienne <[email protected]> wrote:

>
> Are Stored PROCs running in a different backend?
> Are Triggers running in a different backend?
>

No to both.  Whatever backend the SQL to invoke those was sent on is the
backend that executes them.

David J.


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unexpected Backend PID reported by Notification
@ 2024-06-12 06:53  Dominique Devienne <[email protected]>
  parent: David G. Johnston <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Dominique Devienne @ 2024-06-12 06:53 UTC (permalink / raw)
  To: David G. Johnston <[email protected]>; +Cc: [email protected] <[email protected]>

On Tue, Jun 11, 2024 at 5:29 PM David G. Johnston
<[email protected]> wrote:
> On Tuesday, June 11, 2024, Dominique Devienne <[email protected]> wrote:
>> Are Stored PROCs running in a different backend?
>> Are Triggers running in a different backend?
> No to both.  Whatever backend the SQL to invoke those was sent on is the backend that executes them.

Thanks for confirming David (and Adrian). I indeed had two connections
after all. User error. Sorry for the noise. --DD






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-06-12 06:53 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-06-11 15:05 Unexpected Backend PID reported by Notification Dominique Devienne <[email protected]>
2024-06-11 15:29 ` David G. Johnston <[email protected]>
2024-06-12 06:53   ` Dominique Devienne <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox