Re: [BUGS] 10.0: Logical replication doesn't execute BEFORE UPDATE OF <columns> trigger

From: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [BUGS] 10.0: Logical replication doesn't execute BEFORE UPDATE OF <columns> trigger
Date: 2017-10-10 10:26:13
Message-ID: 20171010102613.GA28161@e733.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi Masahiko,

> > I think the cause of this issue is that the apply worker doesn't set
> > updatedCols of RangeTblEntry when applying updates. So TriggerEnabled
> > always ends up with false. I'll make a patch and submit.
> >
>
> Attached patch store the updated columns bitmap set to RangeTblEntry.
> In my environment this bug seems to be fixed by the patch.

Thanks a lot for a quick response. I can confirm that your patch fixes
the issue and passes all tests. Hopefully someone will merge it shortly.

Here is another patch from me. It adds a corresponding TAP test. Before
applying your patch:

```
t/001_rep_changes.pl .. ok
t/002_types.pl ........ ok
t/003_constraints.pl .. 1/5
# Failed test 'check replica trigger with specified list of affected columns applied on subscriber'
# at t/003_constraints.pl line 151.
# got: 'k2|v1'
# expected: 'k2|v1
# triggered|true'
# Looks like you failed 1 test of 5.
t/003_constraints.pl .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
t/004_sync.pl ......... ok
t/005_encoding.pl ..... ok
t/006_rewrite.pl ...... ok
t/007_ddl.pl .......... ok
```

After:

```
t/001_rep_changes.pl .. ok
t/002_types.pl ........ ok
t/003_constraints.pl .. ok
t/004_sync.pl ......... ok
t/005_encoding.pl ..... ok
t/006_rewrite.pl ...... ok
t/007_ddl.pl .......... ok
All tests successful.
```

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
subscription_new_tap_test.patch text/x-diff 2.5 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Giovanni Pisante | Danysoft 2017-10-10 11:22:56 Re: please quote POSTGRESQL
Previous Message Josef Machytka 2017-10-10 09:27:49 Re: BUG #14845: postgres_fdw and mysql_fdw can cause crash of instance

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2017-10-10 10:26:16 More stats about skipped vacuums
Previous Message Ashutosh Bapat 2017-10-10 10:13:11 Re: [POC] hash partitioning