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 <francesco.canovai@enterprisedb.com>
This commit is contained in:
Francesco Canovai 2025-04-17 14:14:16 +02:00 committed by Armando Ruocco
parent 600c721549
commit 8867eab905

View File

@ -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 {