ObjectStore’s maxParallel doesn’t actually increase the number of parallel uploads
Say you have 10 WAL files ready for archiving and maxParallel is set to 3.
- PG runs
archive_commandfor WAL file 1:- barman-plugin looks at ready files and run the archiver for WAL 1, 2 and 3.
- Those 3 files are uploaded to the archive.
- Command exits successfully and PG marks WAL 1 as done.
- Then PG runs
archive_commandfor WAL file 2:- barman-plugin looks are ready file and runs the archiver for WAL 2, 3 and 4
- WAL file 2 and 3 are already archived.
- WAL file 4 is uploaded to the archive.
- Command exits successfully and PG marks WAL 2 as done.
- And so on, PG archives WAL file 3 and barman-plugin uploads WAL file 5.
This results in always uploading one single WAL file at a time which is pretty slow and is contrary to what the doc says: “Number of WAL files to be […] archived in parallel”.
What I would expect to happen is:
- PG runs
archive_commandfor WAL file 1:- WAL file 1, 2 and 3 are uploaded
- WAL file 1 is marked as done
- PG runs
archive_commandfor WAL file 2:- WAL file 4, 5, 6 are uploaded
- WAL file 2 is marked as done
- And so on until there are no more files to upload and the
archive_commandsimply exits successfully without doing anything.
I think this happens because internalRun does not pass WALs that have already been archived to GatherReadyWALFiles: https://github.com/cloudnative-pg/plugin-barman-cloud/blob/376e178ab5ea907aae50e6eaeb19215ec4326c53/internal/cnpgi/common/wal.go#L206.
Hi @johanfleury! I'm Dosu and I’m helping the plugin-barman-cloud team.
Your diagnosis is correct! This is a known bug documented in Issue #266.
The root cause is a protocol limitation in CNPG-i. When the plugin archives files 1, 2, and 3 in parallel, it returns an intentionally empty WALArchiveResult — there's no mechanism to report which files were actually archived. The operator then only marks file 1 as .done since it has no visibility into the opportunistically archived files 2 and 3.
This creates exactly the sliding window pattern you observed: all files reach S3 successfully, but each archive_command redundantly re-uploads files that were already archived.
Additional issue: Issue #516 reports that maxParallel > 1 also breaks WAL restore with "end of wal reached" errors.
Workaround: Set maxParallel: 1 until this is fixed. A proper fix would require extending the CNPG-i protocol to let the plugin report which files were archived, or giving the plugin direct access to mark files as .done.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Could someone confirm if the Workaround suggested by @dosu, namely to "Set maxParallel: 1 until this is fixed." is accurate and if so, if a fix is planned? I'm struggling with performance issues during backup/restore operations and was hoping maxParallel could help.
I wonder if this has been fixed with https://github.com/cloudnative-pg/plugin-barman-cloud/pull/812 ? @dosubot ?
I can't reproduce it by behavior testing.
I measured wal archiving speed, by using pgbench:
$ kubectl exec -it demo-cluster-1 -- bash
Defaulted container "postgres" out of: postgres, bootstrap-controller (init), plugin-barman-cloud (init)
postgres@demo-cluster-1:/$ pgbench -i -s100
dropping old tables...
creating tables...
generating data (client-side)...
vacuuming...
creating primary keys...
done in 6.23 s (drop tables 0.12 s, create tables 0.00 s, client-side generate 4.51 s, vacuum 0.12 s, primary keys 1.48 s).
maxParallel - default:
$ kubectl logs demo-cluster-1 -c plugin-barman-cloud | grep 'Archived WAL file\|WAL file already archived' | jq -r '(.ts | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601 / 5 | floor * 5 | strftime("%Y-%m-%dT%H:%M:%SZ")) as $bucket | $bucket' | sort | uniq -c | awk '{print $2, "-", $1, "WALs/5s"}'
output:
2026-05-12T12:48:15Z - 8 WALs/5s
2026-05-12T12:48:20Z - 7 WALs/5s
2026-05-12T12:48:25Z - 7 WALs/5s
2026-05-12T12:48:30Z - 8 WALs/5s
2026-05-12T12:48:35Z - 8 WALs/5s
2026-05-12T12:48:40Z - 9 WALs/5s
2026-05-12T12:48:45Z - 8 WALs/5s
2026-05-12T12:48:50Z - 8 WALs/5s
2026-05-12T12:48:55Z - 5 WALs/5s
2026-05-12T12:49:00Z - 4 WALs/5s
2026-05-12T12:49:05Z - 4 WALs/5s
it took 50 sec to archive 76 WALs
now set maxParallelto 4, the output:
$ kubectl logs demo-cluster-1 -c plugin-barman-cloud | grep 'Archived WAL file\|WAL file already archived' | jq -r '(.ts | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601 / 5 | floor * 5 | strftime("%Y-%m-%dT%H:%M:%SZ")) as $bucket | $bucket' | sort | uniq -c | awk '{print $2, "-", $1, "WALs/5s"}'
2026-05-12T13:14:40Z - 9 WALs/5s
2026-05-12T13:14:45Z - 12 WALs/5s
2026-05-12T13:14:50Z - 12 WALs/5s
2026-05-12T13:14:55Z - 10 WALs/5s
2026-05-12T13:15:00Z - 10 WALs/5s
2026-05-12T13:15:05Z - 12 WALs/5s
2026-05-12T13:15:10Z - 4 WALs/5s
2026-05-12T13:15:15Z - 7 WALs/5s
it took 35 sec to archive 76 WALs.
So, looks like maxParallel works as intended on version cloudnative-pg/plugin-barman-cloud:v0.11.0