Subject: Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state

From: Ajin Cherian <[email-masked]>
Date: Wed, 26 Mar 2025 21:15:26 +1100

On Wed, Mar 26, 2025 at 9:11 PM cca5507 <[email-masked]> wrote:
>
> Hi,
>
> Thanks for the comments!
>
> Here are the new version patches, I think it will be more clear.
>
> --

+    {
+        /*
+         * Note that during or after BUILDING_SNAPSHOT, we need handle the xlog
+         * that might mark a transaction as catalog modifying because
the snapshot
+         * only tracks catalog modifying transactions. The transaction before
+         * BUILDING_SNAPSHOT will not be tracked anyway(see
SnapBuildCommitTxn()
+         * for details), so just return.
+          */
+        if (SnapBuildCurrentState(builder) >= SNAPBUILD_BUILDING_SNAPSHOT)
+        {
+            /* Currently only XLOG_HEAP2_NEW_CID means a catalog modifying */
+            if (info == XLOG_HEAP2_NEW_CID && TransactionIdIsValid(xid))
+                ReorderBufferXidSetCatalogChanges(ctx->reorder, xid,
buf->origptr);
+        }

Any reason why you avoided calling SnapBuildProcessNewCid here and
only called ReorderBufferXidSetCatalogChanges? If any, please mention
in the comments the reason.

regards,
Ajin Cherian
Fujitsu Australia

---

From: "cca5507" <[email-masked]>
Date: Wed, 26 Mar 2025 20:51:30 +0800

Hi,

There are 3 threads currently.

The latest patches are v4-0001 and v3-0002 in [2].

[1]https://www.postgresql.org/message-id/flat/[email-masked]
[2]https://www.postgresql.org/message-id/flat/[email-masked]
[3]https://www.postgresql.org/message-id/flat/[email-masked]

--
Regards,
ChangAo Chen