首页 > 解决方案 > 是什么导致只读副本上的数据成为 old_snapshot 并导致冲突?

问题描述

多次遇到(在 RDS Postgres 实例上)后:

ERROR: canceling statement due to conflict with recovery
Detail: User query might have needed to see row versions that must be removed

我跑了(在热备上):

SELECT *
FROM pg_stat_database_conflicts;

并发现所有的冲突都与confl_snapshot

这在文档中解释为:

confl_snapshot:此数据库中由于旧快照而取消的查询数

什么可能导致此冲突(作为旧快照)?

如果有帮助,以下是一些相关设置(通过SHOW ALL ;在待机状态下运行):

hot_standby: on
hot_standby_feedback: off
max_standby_archive_delay: 30s
max_standby_streaming_delay: 1h
name,setting
old_snapshot_threshold: -1
vacuum_defer_cleanup_age: 0
vacuum_freeze_min_age: 50000000
vacuum_freeze_table_age: 150000000
vacuum_multixact_freeze_min_age: 5000000
vacuum_multixact_freeze_table_age: 150000000
wal_level: replica
wal_receiver_status_interval: 10s
wal_receiver_timeout: 30s
wal_retrieve_retry_interval: 5s
wal_segment_size: 16MB
wal_sender_timeout: 30s
wal_writer_delay: 200ms

标签: databasepostgresqlamazon-rdsreplication

解决方案


推荐阅读