pgsql: Wait between tablesync worker restarts

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Wait between tablesync worker restarts
Date: 2017-04-28 17:48:21
Message-ID: E1d4A0D-0005NK-Nn@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Wait between tablesync worker restarts

Before restarting a tablesync worker for the same relation, wait
wal_retrieve_retry_interval (currently 5s by default). This avoids
restarting failing workers in a tight loop.

We keep the last start times in a hash table last_start_times that is
separate from the table_states list, because that list is cleared out on
syscache invalidation, which happens whenever a table finishes syncing.
The hash table is kept until all tables have finished syncing.

A future project might be to unify these two and keep everything in one
data structure, but for now this is a less invasive change to accomplish
the original purpose.

For the test suite, set wal_retrieve_retry_interval to its minimum
value, to not increase the test suite run time.

Reviewed-by: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
Reported-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>

Branch
------
master

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

Modified Files
--------------
src/backend/replication/logical/tablesync.c | 58 ++++++++++++++++++++++++++---
src/test/subscription/t/004_sync.pl | 1 +
2 files changed, 53 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2017-04-28 17:53:04 pgsql: Fix crash when partitioned column specified twice.
Previous Message Heikki Linnakangas 2017-04-28 12:24:03 pgsql: Misc SCRAM code cleanups.