PostgreSQL10.0preview功能增強-邏輯訂閱端控制引數解說

德哥發表於2017-04-22

標籤

PostgreSQL , 10.0 , 邏輯訂閱


背景

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


相關文章