Re: Skipping logical replication transactions on subscriber side

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Greg Nancarrow <gregn4422@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>, "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>, "osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com>, Alexey Lesovsky <lesovsky@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-10-18T01:33:37Z
Lists: pgsql-hackers
On Wed, Oct 13, 2021 at 10:59 AM Greg Nancarrow <gregn4422@gmail.com> wrote:
>
> On Tue, Oct 12, 2021 at 4:00 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > I've attached updated patches.
> >
>
> Some comments for the v16-0001 patch:
>

Thank you for the comments!

>
> src/backend/postmaster/pgstat.c
>
> (1) pgstat_vacuum_subworker_stat()
>
> Remove "the" from beginning of the following comment line:
>
> + * the all the dead subscription worker statistics.

Fixed.

>
>
> (2) pgstat_reset_subscription_error_stats()
>
> This function would be better named "pgstat_reset_subscription_subworker_error".

'subworker' contains an abbreviation of 'subscription'. So it seems
redundant to me. No?

>
>
> (3) pgstat_report_subworker_purge()
>
> Improve comment:
>
> BEFORE:
> + * Tell the collector about dead subscriptions.
> AFTER:
> + * Tell the collector to remove dead subscriptions.

Fixed.

>
>
> (4) pgstat_get_subworker_entry()
>
> I notice that in the following code:
>
> + if (create && !found)
> + pgstat_reset_subworker_error(wentry, 0);
>
> The newly-created PgStat_StatSubWorkerEntry doesn't get the "dbid"
> member set, so I think it's a junk value in this case, yet the caller
> of pgstat_get_subworker_entry(..., true) is referencing it:
>
> + /* Get the subscription worker stats */
> + wentry = pgstat_get_subworker_entry(msg->m_subid, msg->m_subrelid, true);
> + Assert(wentry);
> +
> + /*
> + * Update only the counter and timestamp if we received the same error
> + * again
> + */
> + if (wentry->dbid == msg->m_dbid &&
> + wentry->relid == msg->m_relid &&
> + wentry->command == msg->m_command &&
> + wentry->xid == msg->m_xid &&
> + strcmp(wentry->message, msg->m_message) == 0)
> + {
> + wentry->count++;
> + wentry->timestamp = msg->m_timestamp;
> + return;
> + }
>
> Maybe the cheapest solution is to just set dbid in
> pgstat_reset_subworker_error()?

I've change the code to reset dbid in pgstat_reset_subworker_error().

>
>
> src/backend/replication/logical/worker.c
>
> (5) Fix typo
>
> synchroniztion -> synchronization
>
> + * type for table synchroniztion.

Fixed.

Regards,

-- 
Masahiko Sawada
EDB:  https://www.enterprisedb.com/



Commits

  1. Test ALIGNOF_DOUBLE==4 compatibility under ALIGNOF_DOUBLE==8.

  2. Reorder subskiplsn in pg_subscription to avoid alignment issues.

  3. Add ALTER SUBSCRIPTION ... SKIP.

  4. Optionally disable subscriptions on error.

  5. Update docs of logical replication for commit 8d74fc96db.

  6. Respect permissions within logical replication.

  7. Fix regression test failure caused by commit 8d74fc96db.

  8. Add a view to show the stats of subscription workers.

  9. Add logical change details to logical replication worker errcontext.

  10. Rename LOGICAL_REP_MSG_STREAM_END to LOGICAL_REP_MSG_STREAM_STOP.

  11. Fix typo in protocol.sgml.

  12. Remove unused argument in apply_handle_commit_internal().

  13. Fix replication of in-progress transactions in tablesync worker.

  14. Reorder pg_sequence columns to avoid alignment issue