postgresql 为什么在AWS aurora中使用pglogical时订阅状态会关闭?

dly7yett  于 2023-08-04  发布在  PostgreSQL
关注(0)|答案(1)|浏览(149)

我在AWS中部署了两个Aurora postgresql集群11.9和13.4。我按照指令https://aws.amazon.com/blogs/database/part-2-upgrade-your-amazon-rds-for-postgresql-database-using-the-pglogical-extension/将副本从群集11设置到群集13。
节点、replica_set和订阅都在两个集群中成功创建。但是,当我检查目标数据库中的订阅状态时,状态为down:

=> select subscription_name, slot_name, status from pglogical.show_subscription_status();
 subscription_name |                   slot_name                   | status
-------------------+-----------------------------------------------+--------
 ams_subscription1 | pgl_____ngine_ams_mast2d01c59_ams_subsc050888 | down
(1 row)

字符串
在目标数据库日志中,我可以看到以下错误:

2022-03-01 06:34:29 UTC::@:[16329]:LOG: background worker "pglogical apply 16400:3226503298" (PID 29403) exited with exit code 1
2022-03-01 06:35:49 UTC::@:[16329]:LOG: background worker "pglogical apply 16400:3226503298" (PID 1453) exited with exit code 1
2022-03-01 06:38:29 UTC::@:[16329]:LOG: background worker "pglogical apply 16400:3226503298" (PID 10318) exited with exit code 1
----------------------- END OF LOG ----------------------


在源数据库日志中:

2022-03-01 06:34:29 UTC:10.74.105.225(33688):amsMasterUser@AMSEngine:[26786]:ERROR: replication origin "pgl_____ngine_ams_mast2d01c59_ams_subsc050888" does not exist
2022-03-01 06:34:29 UTC:10.74.105.225(33688):amsMasterUser@AMSEngine:[26786]:STATEMENT: SELECT pg_catalog.pg_replication_origin_session_setup('pgl_____ngine_ams_mast2d01c59_ams_subsc050888');
BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET session_replication_role = 'replica';
SET DATESTYLE = ISO;
SET INTERVALSTYLE = POSTGRES;
SET extra_float_digits TO 3;
SET statement_timeout = 0;
SET lock_timeout = 0;

2022-03-01 06:34:29 UTC:10.74.105.225(33688):amsMasterUser@AMSEngine:[26786]:LOG: could not receive data from client: Connection reset by peer
2022-03-01 06:34:29 UTC:10.74.105.225(33684):amsMasterUser@AMSEngine:[26784]:LOG: could not receive data from client: Connection reset by peer
2022-03-01 06:34:29 UTC:10.74.105.225(33684):amsMasterUser@AMSEngine:[26784]:LOG: unexpected EOF on client connection with an open transaction
2022-03-01 06:34:29 UTC:10.74.105.225(33686):amsMasterUser@AMSEngine:[26785]:LOG: could not receive data from client: Connection reset by peer
2022-03-01 06:34:29 UTC:10.74.105.225(33686):amsMasterUser@AMSEngine:[26785]:LOG: unexpected EOF on client connection with an open transaction
----------------------- END OF LOG ----------------------


我可以看到源示例和目标示例中都有错误。但我不知道是什么问题。

92dk7w1h

92dk7w1h1#

根本原因

这是一个非常奇怪的状态,不知道如何克服它和undertand的根本原因,但我已经设法解决这个与以下步骤。
对我们来说,原因是关闭源数据库和目标数据库,这在某种程度上导致了这种不同步状态。
注意:如果您的订阅状态是replicating并且源/目标不同步,那么只运行#additional note中提到的命令,无需应用解析。

分辨率

如果您的订阅状态为down

  • 删除pglogic扩展
  • 再次为发布服务器和订阅服务器数据库创建pglogical配置。

补充说明

最后一步将使订阅返回到replicating状态,对于新条目来说很好,但延迟可能仍然存在。
因此,要确保源表和目标表同步,请运行下面的命令

SELECT pglogical.alter_subscription_resynchronize_table('${SUBSCRIPTION_NAME}', '${SCHEMA_NAME}.${TABLE_NAME}');

字符串
在几分钟内,两个表都同步了数据。

相关问题