Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sx87c-0087zi-Gm for pgsql-general@arkaria.postgresql.org; Sat, 05 Oct 2024 16:59:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sx87a-002JHj-74 for pgsql-general@arkaria.postgresql.org; Sat, 05 Oct 2024 16:59:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sx87Y-002JGh-UD for pgsql-general@lists.postgresql.org; Sat, 05 Oct 2024 16:59:09 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sx87V-002jLh-24 for pgsql-general@lists.postgresql.org; Sat, 05 Oct 2024 16:59:08 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id A07BC13801CF for ; Sat, 5 Oct 2024 12:59:02 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Sat, 05 Oct 2024 12:59:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1728147542; x=1728233942; bh=jMlUAQ0s82fWV4L6ucuwLey4q64ZAVi0ZVvUjzOZNFQ=; b= iqD4UiA1dGJb68y/c9ixWBKQ8Co5JobDmcr5rty2ueRiy3Y/1+ARxCgmYU+cloAz SFHmRCbadNyNF7q4Jdz6Gt5cDBqpetZ0vz/oTeWPKyJ2+pOYgdz5NR2cK3it9mGC zKH5nnMtWqeFyT2rBdsQN2VGqJxQMVTycRLwECFOC1bu88mMjN/uejseV5cELyX4 Dl3e4fSlLF66X11gVCFcl3yBEk3KQ72RevdigzW/k5zdEUjeFy1xvVZrHlsy+JLT WewHraKyi0M3pZHoB1G3ZMWpVGmRWw38VJmpBnRmKr8lWLweT12fNGI2ky1Hkuad +sXte33Ran2BJJiS0KGcNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1728147542; x= 1728233942; bh=jMlUAQ0s82fWV4L6ucuwLey4q64ZAVi0ZVvUjzOZNFQ=; b=c gON7hFSCaKBQ6gTH78zxv0JKUcA6jRpKQ0Y/vJ1DQ5VTPSAt/9epKkeCJ9miu6nZ ACUFS+drEthuXHRU8SUV61cYUbkFbwNoFiPh9bgc8B7VDNYtatsFNXPmr3y6SQBV 0VJYHSRllgzjheYDYUtUE4MuGI3OXXwNYqQ6xI+YO8IXT8rWXfFi0lStaa/pZshe w8W7IWbU3pUwodUgwOqBkeoPKajteZT08xREPSZr3TjFAuWIO/xfBFNnnuqssACs u2S1mwTJLL6RxWbU3L1V7gSOeTlKmYPtiKvkgEeuPVAuJxDgBJ3Wr1saSdE1fT9O /4b55eXm44XoHPFTtDWFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvhedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgg gfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgv rhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrg htthgvrhhnpeeivdfhieehheegueeileejieettdejhedugeefleekvdelkeehtdfgieff feekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthho pedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrg hlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 5 Oct 2024 12:59:01 -0400 (EDT) Message-ID: <368259fb-fd2e-4a05-89e9-a733fae6d964@aklaver.com> Date: Sat, 5 Oct 2024 09:59:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Repeatable Read Isolation Level "transaction start time" To: pgsql-general@lists.postgresql.org References: <28109.1727286817@sss.pgh.pa.us> <20240925215554.gfg24h5sp5aqesxv@hjp.at> <152525.1727302184@sss.pgh.pa.us> <20241005091424.34il2ss4noazgegx@hjp.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: <20241005091424.34il2ss4noazgegx@hjp.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/5/24 02:14, Peter J. Holzer wrote: > On 2024-09-25 18:09:44 -0400, Tom Lane wrote: >> "Peter J. Holzer" writes: >> Admittedly, that would normally not be a very long interval if BEGIN >> did both things ... but on a busy system you could lose the CPU for >> awhile in between. > > Assuming that the system does have a global clock of sufficiently > fine resolution which returns strictly monotonically increasing > timestamps[1], I think the following is true: > > Every snapshot divides the set of transactions into two non-overlapping > subsets: Those which have committed early enough that their effects are > visible in the snapshot and those which haven't. Let's call the first set > the "earlier" transactions and the second the "later" transactions. Let's > call the current transaction c and any transaction in the earlier set e > (we ignore the later transactions for now). > > Performing a commit and taking a snapshot take some time, but there > should be a time t_C(e) in each commit and t_S(c) in the snapshot, such > that t_C(e) < t_S(c) for each "earlier" transaction. Assuming t_C is time of commit and t_S is time of snapshot, is the above not the crux of the matter? Namely when in the current transaction the snapshot is actually taken. That would determine what constitutes an earlier visible transaction relative to the current transaction. In other words I am not seeing how this changes anything? > > Within each transaction each timestamp t which could be visible outside > of the transaction must have been obtained before the commit, > so t(e) < t_C(e) < t_S(c). > > If we choose the transaction_timestamp to be >= t_S, then > transaction_timestamp(e) < t_C(e) < t_S(c) <= transaction_timestamp(c) > and therefore > transaction_timestamp(e) < transaction_timestamp(c) > > Such a guarantee might be useful for some applications and it's not > (IMHO) an entirely unreasonable assumption, but it's not true for > PostgreSQL. So a programmer should be aware of that. > > hp -- Adrian Klaver adrian.klaver@aklaver.com