Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbGYv-0002sm-Rj for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Oct 2021 06:19:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mbGYu-0007H3-OX for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Oct 2021 06:19:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbGYu-0007Gu-ES for pgsql-bugs@lists.postgresql.org; Fri, 15 Oct 2021 06:19:24 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mbGYs-0003RB-2q for pgsql-bugs@lists.postgresql.org; Fri, 15 Oct 2021 06:19:24 +0000 Received: from [192.168.28.53] (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 91F7221C3074 for ; Fri, 15 Oct 2021 09:19:20 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1634278760; bh=7q/qQsieOEIpioNSKD94ulAgeViWenx8PV7b8mZZ+js=; h=To:From:Subject:Date; b=iqGYQE37+L6dDxMC5DCoBVA5J9SC19c8vYatB4ekn/R0VWtyO0gy5j7vqYWR4x+Gi jSMpqA1mRJJTx+TTsMh0cJCyDrK3rBCh2dUi1jLaHaFtK2luqZcSOkNwT4bPvdjw3M JIUoOO7Uw/QkLbYXofNwxaP4zx+jGoQ4OUfqyjsU= To: PostgreSQL mailing lists From: "Andrey V. Lepikhov" Organization: Postgres Professional Subject: SET SESSION AUTHORIZATION command doesn't update status of backend Message-ID: <76ae5aaf-1843-4d84-0430-f35da7f786b9@postgrespro.ru> Date: Fri, 15 Oct 2021 11:19:20 +0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------A419948B55B5A647B63BA3F0" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------A419948B55B5A647B63BA3F0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------A419948B55B5A647B63BA3F0 Content-Type: text/x-patch; charset=UTF-8; name="0001-Bugfix.-Update-a-backend-status-userid-field-after-c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Bugfix.-Update-a-backend-status-userid-field-after-c.pa"; filename*1="tch"