Re: row filtering for logical replication - Mailing list pgsql-hackers

From Greg Nancarrow
Subject Re: row filtering for logical replication
Date
Msg-id CAJcOf-cpxBnBDN-5aS+pa3mzGepS9bogM0aR9e=0qohERdNbqg@mail.gmail.com
Whole thread Raw
In response to RE: row filtering for logical replication  ("tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>)
List pgsql-hackers
On Mon, Nov 15, 2021 at 5:09 PM tanghy.fnst@fujitsu.com
<tanghy.fnst@fujitsu.com> wrote:
>
> I met a problem when using "ALTER PUBLICATION ... SET TABLE ... WHERE ...", the
> publisher was crashed after executing this statement.
>
>
>
> Backtrace is attached. I think maybe the problem is related to the below change in 0003 patch:
>
> +                       free(entry->exprstate);
>

I had a look at this crash problem and could reproduce it.

I made the following changes and it seemed to resolve the problem:

diff --git a/src/backend/replication/pgoutput/pgoutput.c
b/src/backend/replication/pgoutput/pgoutput.c
index e7f2fd4bad..f0cb9b8265 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -969,8 +969,6 @@ pgoutput_row_filter_init(PGOutputData *data,
Relation relation, RelationSyncEntr
             oldctx = MemoryContextSwitchTo(CacheMemoryContext);
             rfnode = n_filters > 1 ? makeBoolExpr(AND_EXPR, rfnodes,
-1) : linitial(rfnodes);
             entry->exprstate = pgoutput_row_filter_init_expr(rfnode);
-
-            list_free(rfnodes);
         }

         entry->rowfilter_valid = true;
@@ -1881,7 +1879,7 @@ rel_sync_cache_relation_cb(Datum arg, Oid relid)
         }
         if (entry->exprstate != NULL)
         {
-            free(entry->exprstate);
+            pfree(entry->exprstate);
             entry->exprstate = NULL;
         }
     }


Regards,
Greg Nancarrow
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: WIP: System Versioned Temporal Table
Next
From: Daniel Gustafsson
Date:
Subject: Re: Unnecessary delay in streaming replication due to replay lag