PostgreSQL 10.0 preview 功能增强 - 逻辑订阅端worker数控制参数

1 minute read

背景

PostgreSQL 逻辑订阅相关文章请参考

《PostgreSQL 10.0 preview 变化 - 逻辑复制pg_hba.conf变化,不再使用replication条目》

《PostgreSQL 10.0 preview 功能增强 - 备库支持逻辑订阅,订阅支持主备漂移了》

《PostgreSQL 10.0 preview 功能增强 - 逻辑复制支持并行COPY初始化数据》

《PostgreSQL 10.0 preview 逻辑复制 - 原理与最佳实践》

另外10.0新增了两个参数,用于控制订阅端的并发。

19.6.4. Subscribers  
  
These settings control the behavior of a logical replication subscriber. Their values on the publisher are irrelevant.  
  
Note that wal_receiver_timeout and wal_retrieve_retry_interval configuration parameters affect the logical replication workers as well.  

1. 订阅端允许同时启动多少个用于apply与初始表同步的worker进程。

apply指流式同步的worker

初始表同步指逻辑订阅初始化COPY源端数据的worker进程。

  • max_logical_replication_workers (int)

Specifies maximum number of logical replication workers.

This includes both apply workers and table synchronization workers.

Logical replication workers are taken from the pool defined by max_worker_processes.

The default value is 4.

2. 每个订阅允许的初始化COPY源端数据的并发数,(即同一个订阅,允许开启多少个并发,从源端COPY初始数据到订阅端。)

  • max_sync_workers_per_subscription (integer)

Maximum number of synchronization workers per subscription.

This parameter controls the amount of paralelism of the initial data copy during the subscription initialization or when new tables are added.

Currently, there can be only one synchronization worker per table.

The synchronization workers are taken from the pool defined by max_logical_replication_workers.

The default value is 2.

patch如下

Add max_sync_workers_per_subscription to postgresql.conf.sample.  
  
author	Fujii Masao <fujii@postgresql.org>	  
Tue, 11 Apr 2017 23:10:54 +0800 (00:10 +0900)  
committer	Fujii Masao <fujii@postgresql.org>	  
Tue, 11 Apr 2017 23:10:54 +0800 (00:10 +0900)  
commit	ff7bce174390ae063c122ab04020bd4ee070d6ad  
tree	12fdc01bc99123086e3693049174dcebd4a06f8b	tree | snapshot  
parent	1c1a4726eba5bb8c0772db8a8efe0315d71887fb	commit | diff  
Add max_sync_workers_per_subscription to postgresql.conf.sample.  
  
This commit also does  
  
- add REPLICATION_SUBSCRIBERS into config_group  
- mark max_logical_replication_workers and max_sync_workers_per_subscription  
  as REPLICATION_SUBSCRIBERS parameters  
- move those parameters into "Subscribers" section in postgresql.conf.sample  
  
Author: Masahiko Sawada, Petr Jelinek and me  
Reported-by: Masahiko Sawada  
Discussion: http://postgr.es/m/CAD21AoAonSCoa=v=87ZO3vhfUZA1k_E2XRNHTt=xioWGUa+0ug@mail.gmail.com  

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=ff7bce174390ae063c122ab04020bd4ee070d6ad

Flag Counter

digoal’s 大量PostgreSQL文章入口