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 1kD6wM-0003PU-CU for pgsql-general@arkaria.postgresql.org; Tue, 01 Sep 2020 14:07:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kD6wL-0007oO-BX for pgsql-general@arkaria.postgresql.org; Tue, 01 Sep 2020 14:07:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD6wL-0007oH-45 for pgsql-general@lists.postgresql.org; Tue, 01 Sep 2020 14:07:13 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD6wI-0008VX-My for pgsql-general@lists.postgresql.org; Tue, 01 Sep 2020 14:07:12 +0000 Received: from walter ([217.245.128.90]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTiHd-1k1Fva3TXJ-00U40Z for ; Tue, 01 Sep 2020 16:07:07 +0200 Date: Tue, 1 Sep 2020 16:07:06 +0200 From: Dirk Lattermann To: pgsql-general@lists.postgresql.org Subject: Re: Trigger transaction isolation Message-ID: <20200901160706.169adf76@walter> In-Reply-To: <20200825111235.2c7193f0@walter> References: <20200825111235.2c7193f0@walter> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:p/F0kaKqtZtrmaMvDSlK+Klx16++fe809jebqgcUW9IzDuDGbXR 3NBZzQoS/IJQEKHabDQgXsEyhjef66eN9tUQ/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nGjdgmm0Ywhx1OMz List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello! Since unfortunately nobody has yet replied to my question, I'd like to know if this is the right list to ask this question on or if I should try another mailing list. Maybe the answer is too obvious, but in that case I'd appreciate a short hint to help me finding it. Maybe it's a hard question, then the answer will be even more interesting...? Thanks again, Dirk Lattermann On Tue, 25 Aug 2020 11:12:35 +0200 Dirk Lattermann wrote: > Hello, > > I'd like to understand the visibility of data changes made by other > transactions when executing SQL commands in a trigger function in READ > COMMITTED isolation level. > I could not find this covered in the trigger documentation (which > already has some good sections about SQL command visibility for > several trigger types), and I don't think it is practically possible > to infer this from observations of the behaviour. > > So, if during an SQL command that triggers a trigger, another > transaction commits, do the SQL commands in the trigger that start > after that commit see the changes of the other transaction or do they > see the state as it was when the triggering command was > started? > > If they do see the changes, then I could implement a > constraint check without race condition based on the contents of some > other table using a lock on that table (say, to check for relation > cycles, or, in the same table, to limit the number of records). > If they don't see the changes, then I fear the race condition free > check can only be implemented using the SERIALIZABLE isolation level, > which I cannot really use in my situation for performance reasons and > the retry overhead. I know that using a lock might lead to a > deadlock, but I'd want to give it a try. > > Thank you very much. > Dirk Lattermann > >