[BUG]: Restore breaks when increasing wal.maxParallel to 8.
Environment
Kubernetes 1.32 CNPG Version: 1.26.1 Plugin Barman Cloud Version: 0.6.0
Observation:
We verify our CNPG Backups nightly by restoring them. Thats when we noticed that most backups can not be restored. When decreasing wal.maxParallel from 8 to 1 in the objectstore it works as expected again. Even previously failed attempts to verify a backup work again.
Sample objectstore configuration:
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: fah-db-backup
namespace: kimi
spec:
configuration:
data:
compression: gzip
destinationPath: s3://XXX/db
endpointURL: https://s3.eu-central-1.ionoscloud.com
historyTags:
backupRetentionPolicy: keep
s3Credentials:
accessKeyId:
key: accessKey
name: kimi-s3-backup
secretAccessKey:
key: secretKey
name: kimi-s3-backup
tags:
backupRetentionPolicy: expire
wal:
compression: gzip
maxParallel: 1
instanceSidecarConfiguration:
env:
- name: AWS_REQUEST_CHECKSUM_CALCULATION
value: when_required
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
value: when_required
retentionPolicyIntervalSeconds: 1800
retentionPolicy: 30d
Here an example of trying to restore a backup:
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
labels:
cnpg-backup-verification: "true"
original-cluster: fah-db
name: fah-db-verify-post-barman
namespace: kimi
spec:
storage:
size: 10Gi
bootstrap:
recovery:
database: kf-fah
owner: kf-fah
secret:
name: fah-db-owner-secret
source: fah-db
env:
- name: AWS_REQUEST_CHECKSUM_CALCULATION
value: when_required
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
value: when_required
externalClusters:
- name: fah-db
plugin:
enabled: true
isWALArchiver: false
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: fah-db-backup
serverName: fah-db
Attached is the complete log of the plugin-barman-cloud sidecar in the CNPG full-recovery job. The critical problem seems to be "end of wal reached" which occurs when restoring with maxParallel 8 but not with maxParallel 1.
Expectation
Restore works independently of the maxParallel setting.
Restore failures with wal.maxParallel > 1 in plugin-barman-cloud are a known issue. The root cause is likely a concurrency bug or race condition in the WAL restore orchestration—parallel restore can trigger premature "end of wal reached" errors if WAL files are missing, incomplete, or if the signaling between parallel workers is faulty. This is confirmed by multiple reports and code analysis: parallel WAL archiving and restore logic may not reliably handle concurrent tasks, especially when maxParallel is set above 1, and there are known bugs with how WAL paths and acknowledgments are managed in parallel mode [source, source, source].
Current workarounds are to set wal.maxParallel to 1, which serializes WAL restore and avoids the bug, or to audit your WAL archiving for completeness and timeline consistency. Setting AWS_REQUEST_CHECKSUM_CALCULATION and AWS_RESPONSE_CHECKSUM_VALIDATION to "when_required" is recommended for S3/MinIO compatibility but does not resolve the parallel restore bug [source].
Restore should work independently of maxParallel, as documented, but in practice, parallel restore is unreliable in current releases. There is no definitive fix in plugin-barman-cloud or CNPG as of v0.6.0/1.26.1, though maintainers are aware and investigating. For now, keep wal.maxParallel at 1 for reliable restores and monitor upstream issues for future fixes.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Same problem happened this week. maxParallel at 8 and the wal-restore was stuck, looping every 5 minutes to fetch always the same 8 files. Deleting the replica and recreating a new one "solve" the issue. The maxParallel parameter is still at 8. Can't manage to reproduce it right now.
This exact thing happened to me recently too. Looping over the same files. Only recourse was to delete the replica.
might this be fixed with https://github.com/cloudnative-pg/plugin-barman-cloud/pull/812 ?