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 1jnUcM-0000UG-Qp for pgsql-general@arkaria.postgresql.org; Mon, 22 Jun 2020 22:08:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnUcL-0007Qc-Nq for pgsql-general@arkaria.postgresql.org; Mon, 22 Jun 2020 22:08:41 +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 1jnUcL-0007QV-Fv for pgsql-general@lists.postgresql.org; Mon, 22 Jun 2020 22:08:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jnUcJ-0000aD-Cc for pgsql-general@lists.postgresql.org; Mon, 22 Jun 2020 22:08:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 05MM8bkA2094137; Mon, 22 Jun 2020 18:08:37 -0400 From: Tom Lane To: AC Gomez cc: PostgreSQL General Subject: Re: Can the current session be notified and refreshed with a new credentials context? In-reply-to: References: Comments: In-reply-to AC Gomez message dated "Mon, 22 Jun 2020 17:07:48 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2094135.1592863717.1@sss.pgh.pa.us> Date: Mon, 22 Jun 2020 18:08:37 -0400 Message-ID: <2094136.1592863717@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk AC Gomez writes: > Suppose you have the following scenario: > 1: Call some function with a certain user and password > 2: From inside that function, have several calls using DBLink > 3: At some point during the running of that function a password rotation(a > separate process) comes along and updates the session user password and the > User Mappings with this new rotated password > 4: Now there is a discrepancy between the password used when the session > started and the password in the User Mappings > 5: The result is that on the next DBLink call the main function will fail > because the session is still running with the old password but we have > changed the User Mappings. > We have proven this by separating out every DBLINK call as its own new > session and running password rotation in between dblink calls. Then things > will work. If you hold the original dblink session open throughout the function, password changes after that session is opened won't matter. Why are you opening new sessions? It's inefficient as well as introducing unnecessary chances for failure. regards, tom lane