Skip to content

Conversation

@piotrszyma
Copy link

Summary

This PR optimizes the WALServiceImplementation.Archive method by introducing a local spool-based check to prevent redundant WAL uploads. This is particularly relevant when maxParallel is set to a value greater than 1.

Similar to how its implemented in plugin-barman-cloud: https://github.com/cloudnative-pg/plugin-barman-cloud/blob/b7b2b5b78755d4fcd7242100cd79df3095b58174/internal/cnpgi/common/wal.go#L177

The Problem

When maxParallel > 1, pgBackRest attempts to archive the requested WAL segment plus the next N−1 segments speculatively. However, PostgreSQL issues WALArchiveRequest calls sequentially (WAL 1, then WAL 2, then WAL 3).

Under the previous implementation, this created a "sliding window" of redundant work:

  • Request WAL 1: Uploads 1, 2, 3.
  • Request WAL 2: Attempts to upload 2, 3, 4 (2 and 3 are redundant).
  • Request WAL 3: Attempts to upload 3, 4, 5 (3 and 4 are redundant).

This resulted in unnecessary network overhead and frequent warnings in the logs regarding files already existing in the repository with the same checksum.

Changes

Added a check against the spool in WALServiceImplementation.Archive. If a WAL segment is already marked as completed in the local spool, the plugin returns a success response immediately without invoking the pgBackRest binary.

@piotrszyma piotrszyma force-pushed the piotrszyma/parallel-spool branch 5 times, most recently from 293b8aa to 82eed86 Compare January 7, 2026 14:04
…tware#45)

Optimizes the WALServiceImplementation. Archive method by introducing a local spool-based check
to prevent redundant WAL uploads. This is particularly relevant when maxParallel is set to a
value greater than 1.

Signed-off-by: Piotr Szyma <thompson2908@gmail.com>
@piotrszyma piotrszyma force-pushed the piotrszyma/parallel-spool branch from 82eed86 to 42ccae4 Compare January 7, 2026 14:07
@Agalin Agalin enabled auto-merge (rebase) January 8, 2026 09:36
@Agalin Agalin merged commit 420c5db into operasoftware:main Jan 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants