Šimon Appelt
11/14/2022, 11:12 AMAlex Marquardt (Airbyte)
11/14/2022, 11:40 AMAlex Marquardt (Airbyte)
11/14/2022, 11:49 AMpg_wal
directory depends on min_wal_size
, max_wal_size
and the amount of WAL generated in previous checkpoint cycles. When old log segment files are no longer needed, they are removed or recycled (that is, renamed to become future segments in the numbered sequence). If, due to a short-term peak of log output rate, max_wal_size
is exceeded, the unneeded segment files will be removed until the system gets back under this limit. Below that limit, the system recycles enough WAL files to cover the estimated need until the next checkpoint, and removes the rest. The estimate is based on a moving average of the number of WAL files used in previous checkpoint cycles. The moving average is increased immediately if the actual usage exceeds the estimate, so it accommodates peak usage rather than average usage to some extent. min_wal_size
puts a minimum on the amount of WAL files recycled for future usage; that much WAL is always recycled for future use, even if the system is idle and the WAL usage estimate suggests that little WAL is needed.
Independently of max_wal_size
, the most recent wal_keep_size megabytes of WAL files plus one additional WAL file are kept at all times. Also, if WAL archiving is used, old segments cannot be removed or recycled until they are archived. If WAL archiving cannot keep up with the pace that WAL is generated, or if archive_command
or archive_library
fails repeatedly, old WAL files will accumulate in pg_wal
until the situation is resolved. A slow or failed standby server that uses a replication slot will have the same effect (see Section 27.2.6).Šimon Appelt
01/02/2023, 10:37 AMDaniel Khoa Le
06/27/2023, 11:51 AM