This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.


Welcome To openGauss Community
Hey @zhangxubo , thanks for your contribution to the community.
Bot Usage Manual
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.
Contact Guide
If you have any questions, please contact the SIG: StorageEngine, AI, CM, CloudNative, SecurityTechnology, SQLEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @Igali, @bihua111, @cailei19, @h_ray, @levy53071, @libiao2024, @lihaixiao, @mrzack, @wangfeihuo, @wuyuechuan, @xiong_xjun, @zhangfengzhi123, @zhangxubo, @zhangzq131, @zjh_hw .


原因分析:


hot_standby_feedback 把备机 GetOldestXmin 写进主库物理槽 xmin,用来挡住主库清理。
主备切换时降主不清这个 xmin,槽留在旧主上变成 inactive,但仍算进 ReplicationSlotsComputeRequiredXmin。
结果:旧主(现备)本地 oldest / feedback 被钉死;新主槽虽可被更高 feedback 往前推(只进不退),但 CSN truncate 的 oldestXact 仍可能停在历史残留水位,两边看起来都不推进。
开关 feedback 后,切换未清理物理槽上的 HS xmin,inactive 残留继续拖 oldestxmin / truncate。


修改后测试步骤:
1.安装主备双节点
gs_guc set -D $PGDATA -c "hot_standby_feedback=on"
gs_ctl reload -D $PGDATA
gs_guc set -D $PGDATA -c "checkpoint_timeout=3min"
gs_ctl reload -D $PGDATA
2.在备机执行gs_ctl switchover -D /data/gauss/data/dn1
3.在备机日志查看,日志第一行是切换完之后,备机的日志看起来并没推进,那是因为全局recentglobalxmin是当时最小值(切换的时候不会被抬高,以当时切换那一瞬间的业务最小值决定),nextid是在切换的时候强制被抬高了一点,所以日志看起来没有推进,需要在主机执行业务后,备机的全局recentglobalxmin才会往前推进,checkpoint时 会通过全局recentglobalxmin 和 所有业务最小xmin 来取最小值去truncate csnlog,不会再把 不活跃槽里面的xmin聚合进来。

4.在主机执行往前推进的业务,create table t1(id int); insert into t1 values(1); insert into t1 values(2); 或者比如 2次 select txid_current(); 等到checkpoint下次到的时候,备机pg_log就可以看到备机cnslog truncate推进,如上图日志的第二行所示;


转测包自验证
旧主(备机) 备机推进后,主机才会推进

新主

切换后,一定是旧主 先推进,新主才推进,不是根据checkpoint的次数决定


回归日期:2026年9月8日
回归结论:通过
回归版本:openGauss7.0.0LTS B021
旧主

新主



测试类型
存储功能
测试版本
7.0.0LTS
问题描述
开启hot_standby_feedback,备机的物理复制槽会带上xmin,在做主备切换后,备机存在不活跃的复制槽带有xmin,csnlog无法清理
操作系统和硬件信息
all
测试环境
企业版主备
被测功能
预置条件
操作步骤
开启hot_standby_feedback,做一次主备切换。

备机上(旧主)存在不活跃的复制槽带有xmin
持续运行,备机上csnlog无法清理

预期输出
备机残留的物理复制槽xmin不阻塞csnlog回收
实际输出
备机残留的物理复制槽xmin阻塞csnlog回收
日志信息
见截图
提单组织
一线客户
测试代码