pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrey V. Lepikhov <a.lepikhov@postgrespro.ru>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: SET SESSION AUTHORIZATION command doesn't update status of backend
Date: Fri, 15 Oct 2021 11:19:20 +0500
Message-ID: <76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru> (raw)

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

view thread (3+ messages)  latest in thread

Message-ID: <76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru>
Permalink:  ../76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru/
Also on:    postgresql.org/message-id/76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: a.lepikhov@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: SET SESSION AUTHORIZATION command doesn't update status of backend
  In-Reply-To: <76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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