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

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state
Date: 2024-08-13 06:19:54
Message-ID: Zrr7CmwrXmdjMNMc@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Aug 13, 2024 at 12:23:04PM +0800, cca5507 wrote:
> Hi,
>
> I refactor the code and fix the git apply warning&nbsp;according to [1].
>
>
> Here are the new version patches.

Thanks!

1 ===

+ /* True if the xlog marks the transaction as containing catalog changes */
+ bool set_catalog_changes = (info == XLOG_HEAP2_NEW_CID);

if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT ||
ctx->fast_forward)
+ {
+ /*
+ * If the transaction contains catalog changes, we need mark it in
+ * reorder buffer before return as the snapshot only tracks catalog
+ * modifying transactions. The transaction before BUILDING_SNAPSHOT
+ * won't be tracked anyway(see SnapBuildCommitTxn), so skip it.
+ */
+ if (set_catalog_changes && TransactionIdIsValid(xid) &&
+ SnapBuildCurrentState(builder) >= SNAPBUILD_BUILDING_SNAPSHOT)
+ ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr);
+
return;
+ }

I still prefer to replace the above with:

if (SnapBuildCurrentState(builder) < SNAPBUILD_BUILDING_SNAPSHOT ||
(SnapBuildCurrentState(builder) == SNAPBUILD_BUILDING_SNAPSHOT && info != XLOG_HEAP2_NEW_CID) ||
ctx->fast_forward)
return;

Let's see what others think.

2 ===

+ /* True if the xlog marks the transaction as containing catalog changes */
+ bool set_catalog_changes = (info == XLOG_HEAP_INPLACE);

if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT ||
ctx->fast_forward)
+ {
+ /*
+ * If the transaction contains catalog changes, we need mark it in
+ * reorder buffer before return as the snapshot only tracks catalog
+ * modifying transactions. The transaction before BUILDING_SNAPSHOT
+ * won't be tracked anyway(see SnapBuildCommitTxn), so skip it.
+ */
+ if (set_catalog_changes && TransactionIdIsValid(xid) &&
+ SnapBuildCurrentState(builder) >= SNAPBUILD_BUILDING_SNAPSHOT)
+ ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr);
+
return;
+ }

I still prefer to replace the above with:

if (SnapBuildCurrentState(builder) < SNAPBUILD_BUILDING_SNAPSHOT ||
(SnapBuildCurrentState(builder) == SNAPBUILD_BUILDING_SNAPSHOT && info != XLOG_HEAP_INPLACE) ||
ctx->fast_forward)
return;

Let's see what others think.

3 ===

I re-read your comments in [0] and it looks like you've concern about
the 2 "if" I'm proposing above and the fast forward handling. Is that the case
or is your fast forward concern unrelated to my proposals?

Not sure what happened but it looks like your reply in [0] is not part of the
initial thread [1], but created a new thread instead, making the whole
conversation difficult to follow.

[0]: https://www.postgresql.org/message-id/tencent_8DEC9842690A9B6AFD52D4659EF0700E9409%40qq.com
[1]: https://www.postgresql.org/message-id/flat/tencent_6AAF072A7623A11A85C0B5FD290232467808%40qq.com

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-08-13 06:23:10 Re: Thread-safe nl_langinfo() and localeconv()
Previous Message Thomas Munro 2024-08-13 05:47:46 Re: Remaining dependency on setlocale()