diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 744c5e8..5a0e467 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3474,6 +3474,21 @@ ANY num_sync ( + table_sync_retry_interval (integer) + + table_sync_retry_interval configuration parameter + + + + + Specify how long the subscriber should wait before retrying to copy the initial + data after a failed attempt. The default is 5 seconds. Units + are milliseconds if not specified. + + + + diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index fecff93..0ec57a4 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -58,6 +58,7 @@ int max_logical_replication_workers = 4; int max_sync_workers_per_subscription = 2; +int table_sync_retry_interval = 5000; LogicalRepWorker *MyLogicalRepWorker = NULL; diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index a067fe3..c8637f9 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -395,11 +395,21 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn) */ else if (!syncworker && nsyncworkers < max_sync_workers_per_subscription) { - logicalrep_worker_launch(MyLogicalRepWorker->dbid, - MySubscription->oid, - MySubscription->name, - MyLogicalRepWorker->userid, - rstate->relid); + static TimestampTz last_start_time = 0; + TimestampTz now; + + now = GetCurrentTimestamp(); + + if (TimestampDifferenceExceeds(last_start_time, now, + table_sync_retry_interval)) + { + logicalrep_worker_launch(MyLogicalRepWorker->dbid, + MySubscription->oid, + MySubscription->name, + MyLogicalRepWorker->userid, + rstate->relid); + last_start_time = now; + } } } } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 19d258d..7e32d57 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2621,6 +2621,18 @@ static struct config_int ConfigureNamesInt[] = }, { + {"table_sync_retry_interval", PGC_SIGHUP, REPLICATION_STANDBY, + gettext_noop("Sets the time to wait before retrying to launch table " + "synchronization worker after a failed attempt."), + NULL, + GUC_UNIT_MS + }, + &table_sync_retry_interval, + 5000, 1, INT_MAX, + NULL, NULL, NULL + }, + + { {"wal_retrieve_retry_interval", PGC_SIGHUP, REPLICATION_STANDBY, gettext_noop("Sets the time to wait before retrying to retrieve WAL " "after a failed attempt."), diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 512be0a..bf2af18 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -272,6 +272,8 @@ # in milliseconds; 0 disables #wal_retrieve_retry_interval = 5s # time to wait before retrying to # retrieve WAL after a failed attempt +#table_sync_retry_interval = 5s # time to wait before retyring to + # synchronize table after a failed attempt #------------------------------------------------------------------------------ diff --git a/src/include/replication/logicallauncher.h b/src/include/replication/logicallauncher.h index 060946a..e9ea7da 100644 --- a/src/include/replication/logicallauncher.h +++ b/src/include/replication/logicallauncher.h @@ -14,6 +14,7 @@ extern int max_logical_replication_workers; extern int max_sync_workers_per_subscription; +extern int table_sync_retry_interval; extern void ApplyLauncherRegister(void); extern void ApplyLauncherMain(Datum main_arg);