From: | Dominique Devienne <ddevienne(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Unexpected Backend PID reported by Notification |
Date: | 2024-06-11 15:05:57 |
Message-ID: | CAFCRh-8cwTFBeTS2_7n97e5C42i-pTVw5o+vyqnwxesQFLbp_A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(), "...");
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2024-06-11 15:21:07 | Re: Unexpected Backend PID reported by Notification |
Previous Message | Rich Shepard | 2024-06-11 12:28:45 | Re: Gaps in PK sequence numbers [RESOLVED] |