Previously, CheckPointReplicationSlots() ran at the start of CheckPointGuts(), while WAL cleanup occurred much later in CreateCheckPoint() and CreateRestartPoint(), after the buffer write and ProcessSyncRequests() phases. During a spread checkpoint, this gap could be several minutes. During that time, active replication slots could advance their restart_lsn. However, replicationSlotMinLSN had already been computed from the older saved values. As a result, KeepLogSeg() could retain WAL segments that were no longer needed, causing unnecessary pg_wal growth until the next checkpoint or restartpoint. Fix this by moving CheckPointReplicationSlots(), CheckPointSnapBuild(), and CheckPointLogicalRewriteHeap() to just before CheckPointTwoPhase(), after the buffer write and ProcessSyncRequests() phases. This makes WAL retention decisions use the latest replication slot state. The logical snapshot and rewrite heap cleanup decisions also benefit from the updated saved restart_lsn. Author: Ants Aasma <ants@cybertec.at> Author: Hüseyin Demir <huseyin.d3r@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/CANwKhkPCBcTQ_pk06MD5W5YYNnuYHp8dLNuOUz8-5pMBMPY1Bw%40mail.gmail.com
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.