From: pgstef (@pgstef) <noreply+pgstef@github.com>
To: pgbackrest/pgbackrest <noreply+pgbackrest-pgbackrest@github.com>
Subject: Re: [pgbackrest/pgbackrest] PR #2917: Add an info helper to load, cache, and save info files.
Date: Fri, 13 Nov 2026 09:46:08 +0000
Message-ID: <gh-pgbackrest-pgbackrest-2917-r5888995026@github.com> (raw)
In-Reply-To: <gh-pgbackrest-pgbackrest-2917@github.com>
References: <gh-pgbackrest-pgbackrest-2917@github.com>
The helper approach looks good to me! However, if I'm reading the code correctly, there might be a small issue with the initialization order in `infoArchiveRepoIdxSave()` and `infoBackupRepoIdxSave()`.
Both currently pass their info accessor (`infoHelperArchive(repoIdx)` or `infoHelperBackup(repoIdx)`), `storageRepoIdxWrite(repoIdx)`, and `cfgCipherSpecMainIdx(repoIdx)` as arguments to the same save call. Since C doesn't guarantee argument evaluation order, the cipher spec can be resolved before the remote repository has provided its cipher options. This looks like the same ordering issue addressed by `078489fa3`.
On a PostgreSQL host where encryption is configured only on the remote repository host, this can cache a `none` cipher spec. Initializing storage afterwards updates the cipher options but leaves that cached spec unchanged. A `Set` followed by `Save` as the first repository access can therefore write the info file without encryption.
The current callers appear to initialize repository storage first, so this looks like a latent issue rather than a regression in an existing command. Still, since the helper is intended to handle this initialization itself, could we make the ordering explicit in both save functions, as the load paths already do?
In `infoArchiveRepoIdxSave()`, replace the save call with:
```c
InfoArchive *const infoArchive = infoHelperArchive(repoIdx);
// Initialize repo storage before resolving the cipher spec, even when the info is already cached.
const Storage *const storage = storageRepoIdxWrite(repoIdx);
infoArchiveSaveFile(infoArchive, storage, INFO_ARCHIVE_PATH_FILE_STR, cfgCipherSpecMainIdx(repoIdx));
```
And similarly in `infoBackupRepoIdxSave()`:
```c
InfoBackup *const infoBackup = infoHelperBackup(repoIdx);
// Initialize repo storage before resolving the cipher spec, even when the info is already cached.
const Storage *const storage = storageRepoIdxWrite(repoIdx);
infoBackupSaveFile(infoBackup, storage, INFO_BACKUP_PATH_FILE_STR, cfgCipherSpecMainIdx(repoIdx));
```
Does that make sense, or am I missing something about the initialization order?