Re: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT - Mailing list pgsql-hackers

From cca5507
Subject Re: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT
Date
Msg-id tencent_B9A98301BBAD509AC2BD5A82942C9917BC07@qq.com
Whole thread Raw
In response to Re: Re: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT  (Ajin Cherian <itsajin@gmail.com>)
Responses Re: Fix logical decoding not track transaction during SNAPBUILD_BUILDING_SNAPSHOT
List pgsql-hackers
> Looks like the assert in ReorderBufferForget failed because
> ninvalidations is not 0.

I think it can be fixed by this:

```
@@ -282,18 +286,24 @@ xact_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
             {
                 TransactionId xid;
                 xl_xact_invals *invals;
+                bool has_snapshot;
 
                 xid = XLogRecGetXid(r);
                 invals = (xl_xact_invals *) XLogRecGetData(r);
+                has_snapshot =
+                    SnapBuildCurrentState(builder) >= SNAPBUILD_FULL_SNAPSHOT;
 
                 /*
                  * Execute the invalidations for xid-less transactions,
                  * otherwise, accumulate them so that they can be processed at
                  * the commit time.
+                 *
+                 * Note that we only need to do this when we are not fast-forwarding
+                 * and there is a snapshot.
                  */
                 if (TransactionIdIsValid(xid))
                 {
-                    if (!ctx->fast_forward)
+                    if (!ctx->fast_forward && has_snapshot)
                         ReorderBufferAddInvalidations(reorder, xid,
                                                       buf->origptr,
                                                       invals->nmsgs,
@@ -301,7 +311,7 @@ xact_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
                     ReorderBufferXidSetCatalogChanges(ctx->reorder, xid,
                                                       buf->origptr);
                 }
-                else if (!ctx->fast_forward)
+                else if (!ctx->fast_forward && has_snapshot)
                     ReorderBufferImmediateInvalidation(ctx->reorder,
                                                        invals->nmsgs,
                                                        invals->msgs);
```

--
Regards,
ChangAo Chen

pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Add SECURITY_INVOKER_VIEWS option to CREATE DATABASE
Next
From: Zhang Mingli
Date:
Subject: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects