pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SET SESSION AUTHORIZATION command doesn't update status of backend
3+ messages / 3 participants
[nested] [flat]

* SET SESSION AUTHORIZATION command doesn't update status of backend
@ 2021-10-15 06:19  Andrey V. Lepikhov <a.lepikhov@postgrespro.ru>
  0 siblings, 1 reply; 3+ messages in thread

From: Andrey V. Lepikhov @ 2021-10-15 06:19 UTC (permalink / raw)
  To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Hi,

Nikita Degtyarev (n.degtyarev@postgrespro.ru) reported a suspicious 
behaviour of a SET SESSION AUTHORIZATION command. If you switch user in 
a session:

CREATE USER abc;
SET SESSION AUTHORIZATION abc;

command "SELECT SESSION_USER, CURRENT_USER" shows us:

  session_user | current_user
--------------+--------------
  abc          | abc

But if you launch a job:
SELECT pg_sleep(60);

and will see into the pg_stat_activity:

SELECT usename,query FROM pg_stat_activity
WHERE backend_type = 'client backend';

it tell you that this job is executing with the original user:

  usename |                   query
---------+--------------------------------------------
  andrey  | SELECT usename,query FROM pg_stat_activity+
          | WHERE backend_type = 'client backend';
  abc     | SELECT pg_sleep(60);

The deal is in missed update of PgBackendStatus after updating of 
session user.
The attached patch fixes this bug.

-- 
regards,
Andrey Lepikhov
Postgres Professional

Attachments:

  0001-Bugfix.-Update-a-backend-status-userid-field-after-c.patch (text/x-patch, 0B) download

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

* Re: SET SESSION AUTHORIZATION command doesn't update status of backend
@ 2021-10-15 13:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andrey V. Lepikhov <a.lepikhov@postgrespro.ru>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2021-10-15 13:50 UTC (permalink / raw)
  To: Andrey V. Lepikhov <a.lepikhov@postgrespro.ru>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

"Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru> writes:
> Nikita Degtyarev (n.degtyarev@postgrespro.ru) reported a suspicious 
> behaviour of a SET SESSION AUTHORIZATION command. If you switch user in 
> a session:
> [ pg_stat_activity doesn't change ]

I don't think this is a bug.  pg_stat_activity is reporting the session's
login identity, and that seems fine, though maybe the documentation about
it needs to be clarified.

			regards, tom lane





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

* Re: SET SESSION AUTHORIZATION command doesn't update status of backend
@ 2021-10-15 17:44  Andrey Lepikhov <a.lepikhov@postgrespro.ru>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Andrey Lepikhov @ 2021-10-15 17:44 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On 15/10/21 18:50, Tom Lane wrote:
> I don't think this is a bug.  pg_stat_activity is reporting the session's
> login identity, and that seems fine, though maybe the documentation about
> it needs to be clarified.
Thank you. Documentation is quite correct. I should be more attentive.

-- 
regards,
Andrey Lepikhov
Postgres Professional





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


end of thread, other threads:[~2021-10-15 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 06:19 SET SESSION AUTHORIZATION command doesn't update status of backend Andrey V. Lepikhov <a.lepikhov@postgrespro.ru>
2021-10-15 13:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-10-15 17:44   ` Andrey Lepikhov <a.lepikhov@postgrespro.ru>

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