﻿# PostgreSQL preserves non-relation backup files replaced by atomic rename

Atomic rename at the source did not guarantee a coherent backup copy; 18.7 fixes truncation and zero-padding of replaced non-relation files.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-ops-postgres-basebackup-atomic-rename-files/
Language: en

PostgreSQL 18.7 fixes incorrect base-backup copies of non-relation files that are replaced through atomic rename. The release names postgresql.auto.conf as an example: concurrent replacement could leave the backup copy truncated or zero-padded. Atomic replacement protects the live filename’s update boundary, but it does not automatically make a backup reader’s separate size and content observations refer to the same file instance.

## A filename can identify different file instances

The release’s example is a file routinely replaced rather than edited through one stable instance. A proposed test alternates valid configurations of noticeably different lengths while a base backup runs. The captured file should correspond to a valid source version, not a mixture of size expectations and another instance’s bytes. Use deliberately distinct contents so a plausible file length cannot conceal truncation or padding of an otherwise recognizable prefix.

## Source atomicity does not cover the reader’s protocol

An atomic rename gives readers a useful pathname transition, but a backup algorithm can still combine observations taken before and after replacement. The fix concerns that copy protocol. A serial copy of a static configuration would not test it. Qualification should establish the replacement overlap and inspect the final backup artifact, while avoiding a claim that every live configuration change must appear in the backup; consistency of one allowed version is the relevant boundary.

## Restore checks must include configuration meaning

A backup can contain readable relation data while a damaged configuration file changes or prevents startup. A proposed restore exercise checks the copied file’s parseability and expected settings in the isolated target. Archive readability alone is insufficient. The release does not claim that every zero byte causes an identical startup error, so tests should inspect both file content and resulting configuration rather than depend on one invented diagnostic string.

## Do not confuse this with torn control-file copying

A concurrently written pg_control file is another repair in this release, but atomic replacement of a non-relation file is a distinct mechanism. The expected tests and artifacts differ. This patch’s operational result is faithful copying despite file replacement, not a general promise of an atomic snapshot across every file in a base backup. Keep the relevant backup protocol and recovery requirements explicit when interpreting a passing targeted test.

## Sources

- [PostgreSQL 18.7 release notes](https://www.postgresql.org/docs/release/18.7/)
- [PostgreSQL upstream change b09b26ac8](https://postgr.es/c/b09b26ac8)

## Related reading

- [A consistent PostgreSQL restore can predate a document deletion](/journal/field-sovereign-postgres-recovery-target-deleted-document-eligibility/)
- [PostgreSQL timeouts protect different transaction intervals](/journal/postgres-statement-transaction-idle-timeout-scope/)
