繁体   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