pgsql: Review logical replication tablesync code

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Review logical replication tablesync code
Date: 2020-10-15 14:36:55
Message-ID: E1kT4ND-0001QT-QA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Review logical replication tablesync code

Most importantly, remove optimization in LogicalRepSyncTableStart that
skips the normal walrcv_startstreaming/endstreaming dance. The
optimization is not critically important for production uses anyway,
since it only fires in cases with no activity, and saves an
uninteresting amount of work even then. Critically, it obscures bugs by
hiding the interesting code path from test cases.

Also: in GetSubscriptionRelState, remove pointless relation open; access
pg_subscription_rel->srsubstate with GETSTRUCT as is typical rather than
SysCacheGetAttr; remove unused 'missing_ok' argument.
In wait_for_relation_state_change, use explicit catalog snapshot
invalidation rather than obscurely (and expensively) through
GetLatestSnapshot.
In various places: sprinkle comments more liberally and rewrite a number
of them. Other cosmetic code improvements.

No backpatch, since no bug is being fixed here.

Author: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reviewed-by: Petr Jelínek <petr(dot)jelinek(at)2ndquadrant(dot)com>
Discussion: https://postgr.es/m/20201010190637.GA5774@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b05fe7b442fd185b9705c537adb602b3b9d49518

Modified Files
--------------
src/backend/catalog/pg_subscription.c | 27 +--
src/backend/replication/logical/relation.c | 3 +-
src/backend/replication/logical/tablesync.c | 261 +++++++++++++---------------
src/backend/replication/logical/worker.c | 15 +-
src/include/catalog/pg_subscription_rel.h | 3 +-
5 files changed, 131 insertions(+), 178 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2020-10-15 16:14:57 pgsql: Install pg_isolation_regress and isolationtester
Previous Message Heikki Linnakangas 2020-10-15 14:09:56 pgsql: Refactor code for cross-partition updates to a separate function