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 1sx8UK-008A2F-CK for pgsql-general@arkaria.postgresql.org; Sat, 05 Oct 2024 17:22:40 +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 1sx8UI-002a32-Pl for pgsql-general@arkaria.postgresql.org; Sat, 05 Oct 2024 17:22:38 +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 1sx8UI-002a2d-BM for pgsql-general@lists.postgresql.org; Sat, 05 Oct 2024 17:22:38 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sx8UB-002jUS-NA for pgsql-general@lists.postgresql.org; Sat, 05 Oct 2024 17:22:37 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2fac187eef2so37859301fa.3 for ; Sat, 05 Oct 2024 10:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728148951; x=1728753751; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/FvsLpdjhh2KAv12QKlRrJTwM8U6X1Aivj8/Th63DaI=; b=g+Jvih/XJeJy9des7Q90CrOXDoiyL9rhJdA6xg1oi8Hhrgy2bL02rCBXmuvdJJd6S0 QewlPYbFeXtC/g7lL1WyHAMFKWkKrFfLhfFDAzARv83r7ETVlHrnVRNSgKR2UdGY+Bxf +omqPjrTNMoO5ziX56/iU+4ORd2GPRqZ8u2QAa+WViXJsI99ootE11HkvZP9wAKuVyG8 gm/+tN8zHuWNYoEbYlAgQY7SUXVbdp1owxTl4V/Pd+VopZPEPxUygOtNTwUmrMGiAS2l Va0BC8MhXgP3EIb8iReZ2vP+mBHrDfowqCWCL1xHVmGmWTIBOJePL6YPvnAJEvwkUooB 7/DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728148951; x=1728753751; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/FvsLpdjhh2KAv12QKlRrJTwM8U6X1Aivj8/Th63DaI=; b=AJtsiU8ls5LK8ej7v4Ok6b3JTGO1vRzycza8kO4G/di9rXGZxzV5MxNjWcI0k0OJ/w KZIqge5lkW3t05mFgInb0L0+fKlu7mMXeDmEqV8NH8YhVfbpBfnhLKqxCxTq2kNN246U uU0ZTKxh2hW4gAIowabPYEqoVDs9qd+UN2Uy/qDgrYol4Olobewx7m8dZZq68ufljjKK i20KPaYnb3uABANoUXiA1q+jRVRO3/YoEYSPvQyj4qPFw0vhuwf077XXYMypsiG5zNMX AyWsVr5k59NtVPZgW0+Y+RxVPAtEdaG6C4GQHSYtgUO7tnvVyAS5mkW7bhlaDXUdUb5T Qasw== X-Gm-Message-State: AOJu0YyGBM31VQ7VKNeelnCcAhn5hfYN+u7ocvmjjn2PS8NJu2MUpxL6 htZDJNRGMzbrXXpr8PNotaWvI/vqtWd7vdVv4NmajzkZeuXzYNuOREx7X2qrBW3fGtNc4WbDie0 UEjw65smydcQ8LSC6ewGvDzsHp68UnA== X-Google-Smtp-Source: AGHT+IEf831PdyEtKVdwsKyiH6nZvrzF0gYtEtJiqS6iJz6C1BM7hCl+Cq3hGi0wT9SyaaIkabbT6MGyeqf6jlfS5Ag= X-Received: by 2002:a05:651c:508:b0:2f1:a30c:cd15 with SMTP id 38308e7fff4ca-2faf3d98d14mr30306231fa.36.1728148950252; Sat, 05 Oct 2024 10:22:30 -0700 (PDT) MIME-Version: 1.0 References: <28109.1727286817@sss.pgh.pa.us> <20240925215554.gfg24h5sp5aqesxv@hjp.at> <152525.1727302184@sss.pgh.pa.us> <20241005091424.34il2ss4noazgegx@hjp.at> <368259fb-fd2e-4a05-89e9-a733fae6d964@aklaver.com> In-Reply-To: <368259fb-fd2e-4a05-89e9-a733fae6d964@aklaver.com> From: Greg Sabino Mullane Date: Sat, 5 Oct 2024 13:21:54 -0400 Message-ID: Subject: Re: Repeatable Read Isolation Level "transaction start time" To: Adrian Klaver Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/mixed; boundary="0000000000004cfd530623be086f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004cfd530623be086f Content-Type: multipart/alternative; boundary="0000000000004cfd500623be086d" --0000000000004cfd500623be086d Content-Type: text/plain; charset="UTF-8" While working on a doc patch for this, I realized that the situation is worse than I originally thought. This means that anyone relying on pg_stat_activity.xact_start is not really seeing the time of the snapshot. They are seeing the time that BEGIN was issued. Further, there is no way to tell (AFAICT) when the snapshot was granted (i.e. when the transaction actually started for purposes of MVCC comparisons). All we can guarantee via pg_stat_activity is that if xact_start and query_start *are* identical, no snapshot has been granted yet, and if they are not identical, then the snapshot *might* have been granted, might not (depending on SHOW vs SELECT for example). I suppose checking "query" could show that, but all you have then is a general window saying that the snapshot was created sometime after xact_start but no later than query_start (and could be a lot earlier if this ain't query number one). Maybe we doc patch pg_stat_activity too? Actually, let me just post my quick work-in-progress patch here in the meantime for discussion. Cheers, Greg --0000000000004cfd500623be086d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
While working on a doc patch for this, I realized that the= situation is worse than I originally thought. This means that anyone relyi= ng on pg_stat_activity.xact_start is not really seeing the time of the snap= shot. They are seeing the time that BEGIN was issued. Further, there is no = way to tell (AFAICT) when the snapshot was granted (i.e. when the transacti= on actually started for purposes of MVCC comparisons). All we can guarantee= via pg_stat_activity is that if xact_start and query_start *are* identical= , no snapshot has been granted yet, and if they are not identical, then the= snapshot *might* have been granted, might not (depending on SHOW vs SELECT= for example). I suppose checking "query" could show that, but al= l you have then is a general window saying that the snapshot was created so= metime after xact_start but no later than query_start (and could be a lot e= arlier if this ain't query number one).

Maybe we doc= patch pg_stat_activity too? Actually, let me just post my quick work-in-pr= ogress patch here in the meantime for discussion.

= Cheers,
Greg


--0000000000004cfd500623be086d-- --0000000000004cfd530623be086f Content-Type: application/octet-stream; name="0001-Clarify-READ-REPEATABLE-behavior-a-bit-more.patch" Content-Disposition: attachment; filename="0001-Clarify-READ-REPEATABLE-behavior-a-bit-more.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_m1wf6ws40 RnJvbSA3OWEzN2Q4ZWI0NDk1ODNlNTI2ZGU3ZjZhMTdiZGNjYWRkMjQzM2VlIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBHcmVnIFNhYmlubyBNdWxsYW5lIDxncmVnQHR1cm5zdGVwLmNv bT4KRGF0ZTogU2F0LCA1IE9jdCAyMDI0IDEzOjE5OjI3IC0wNDAwClN1YmplY3Q6IFtQQVRDSF0g Q2xhcmlmeSBSRUFEIFJFUEVBVEFCTEUgYmVoYXZpb3IgYSBiaXQgbW9yZQoKLS0tCiBkb2Mvc3Jj L3NnbWwvbXZjYy5zZ21sIHwgMTIgKysrKysrKysrKysrCiAxIGZpbGUgY2hhbmdlZCwgMTIgaW5z ZXJ0aW9ucygrKQoKZGlmZiAtLWdpdCBhL2RvYy9zcmMvc2dtbC9tdmNjLnNnbWwgYi9kb2Mvc3Jj L3NnbWwvbXZjYy5zZ21sCmluZGV4IDM4MGQwYzllODAuLjI5NWMzMGUzZmUgMTAwNjQ0Ci0tLSBh L2RvYy9zcmMvc2dtbC9tdmNjLnNnbWwKKysrIGIvZG9jL3NyYy9zZ21sL212Y2Muc2dtbApAQCAt NTE2LDYg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