From 8867eab90516ae5e366c555ea02f11152a30481d Mon Sep 17 00:00:00 2001 From: Francesco Canovai Date: Thu, 17 Apr 2025 14:14:16 +0200 Subject: [PATCH] fix: off by 1 error in parallel work archive Fix an error in which the amount of workers archived in parallel was the wal the archive command was called on + the maxParallel, actually using one worker more than requested. Signed-off-by: Francesco Canovai --- internal/cnpgi/common/wal.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/cnpgi/common/wal.go b/internal/cnpgi/common/wal.go index b09fb73..7974010 100644 --- a/internal/cnpgi/common/wal.go +++ b/internal/cnpgi/common/wal.go @@ -146,7 +146,7 @@ func (w WALServiceImplementation) Archive( } } if isDeletedFromSpool { - contextLogger.Info("Archived WAL file (parallel)", + contextLogger.Info("WAL file already archived, skipping", "walName", baseWalName) return nil, nil } @@ -158,14 +158,15 @@ func (w WALServiceImplementation) Archive( } maxParallel := 1 - if objectStore.Spec.Configuration.Wal != nil { + if objectStore.Spec.Configuration.Wal != nil && objectStore.Spec.Configuration.Wal.MaxParallel > 0 { maxParallel = objectStore.Spec.Configuration.Wal.MaxParallel } + maxResults := maxParallel - 1 walFilesList := walUtils.GatherReadyWALFiles( ctx, walUtils.GatherReadyWALFilesConfig{ - MaxResults: maxParallel, + MaxResults: maxResults, SkipWALs: []string{baseWalName}, PgDataPath: w.PGDataPath, }, @@ -174,6 +175,7 @@ func (w WALServiceImplementation) Archive( // Ensure the requested WAL file is always the first one being // archived walFilesList.Ready = append([]string{request.GetSourceFileName()}, walFilesList.Ready...) + contextLogger.Debug("WAL files to archive: %v", "walFilesListReady", walFilesList.Ready) result := arch.ArchiveList(ctx, walFilesList.ReadyItemsToSlice(), options) for _, archiverResult := range result {