簡體   English   中英

postgresql 訂閱不適用於公共以外的模式

[英]postgresql subscription not working for schemas other than public

我正在嘗試使用兩個本地 postgresql 服務器(node1:端口 5434,node2:端口 5435)創建邏輯復制。

我可以成功地在 node1 和 node2 上為公共模式中的表創建發布和訂閱。

節點1:

CREATE PUBLICATION my_pub FOR TABLE t1;
GRANT SELECT ON t1 TO repuser;

節點2:

CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5434 dbname=pub user=repuser password=password' PUBLICATION my_pub;

Node2 public.t1 復制 node1 public.t1 中的所有數據。

但是,我的問題是當我使用相同的代碼但在不同的模式中創建發布和訂閱時,node2 無法復制。

下面是一些 pg_catalog 查詢的 output:

節點1:

pub=# select * from pg_catalog.pg_publication_tables;
 pubname  | schemaname | tablename
----------+------------+-----------
 my_pub   | public     | t1
 cdl_test | cdl        | t1
 pub_test | test       | t1

節點2:

sub=# \dRs
              List of subscriptions
     Name     |  Owner   | Enabled | Publication
--------------+----------+---------+-------------
 cdl_sub_test | postgres | t       | {cdl_test}
 my_sub       | postgres | t       | {my_pub}
 sub_test     | postgres | t       | {pub_test}

sub=# select * from pg_catalog.pg_replication_origin;
 roident |  roname
---------+----------
       2 | pg_18460
       1 | pg_18461
       3 | pg_18466

sub=# select * from pg_catalog.pg_subscription_rel ;
 srsubid | srrelid | srsubstate |  srsublsn
---------+---------+------------+------------
   18461 |   16386 | r          | 0/3811C810
   18466 |   18463 | d          |
   18460 |   18456 | d          |

正如select * from pg_catalog.pg_subscription_rel中所示,測試和 cdl 模式的兩個訂閱位於d(data is being copied) state。

關於如何 go 關於此問題或診斷問題發生原因的任何建議?

正如 jjanes 所建議的,日志文件的片段如下所示:

2022-01-17 16:05:25.165 PST [622] WARNING:  out of logical replication worker slots
2022-01-17 16:05:25.165 PST [622] HINT:  You might need to increase max_logical_replication_workers.
2022-01-17 16:05:25.168 PST [970] LOG:  logical replication table synchronization worker for subscription "cdl_sub_test", table "t1" has started
2022-01-17 16:05:25.245 PST [970] ERROR:  could not start initial contents copy for table "cdl.t1": ERROR:  permission denied for schema cdl
2022-01-17 16:05:25.247 PST [471] LOG:  background worker "logical replication worker" (PID 970) exited with exit code 12022-01-17 16:05:25.797 PST [488] postgres@sub LOG:  statement: /*pga4dash*/

即使在我授予SELECT ON cdl.t1 TO repuser; .

您必須授予用戶repuser讀取應復制的表的權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM