Skip to content

Commit 104e5b2

Browse files
committed
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>
1 parent 3f0e8fd commit 104e5b2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

internal/cnpgi/common/wal.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (w WALServiceImplementation) Archive(
146146
}
147147
}
148148
if isDeletedFromSpool {
149-
contextLogger.Info("Archived WAL file (parallel)",
149+
contextLogger.Info("WAL file already archived, skipping",
150150
"walName", baseWalName)
151151
return nil, nil
152152
}
@@ -158,14 +158,15 @@ func (w WALServiceImplementation) Archive(
158158
}
159159

160160
maxParallel := 1
161-
if objectStore.Spec.Configuration.Wal != nil {
161+
if objectStore.Spec.Configuration.Wal != nil && objectStore.Spec.Configuration.Wal.MaxParallel > 0 {
162162
maxParallel = objectStore.Spec.Configuration.Wal.MaxParallel
163163
}
164164

165+
maxResults := maxParallel - 1
165166
walFilesList := walUtils.GatherReadyWALFiles(
166167
ctx,
167168
walUtils.GatherReadyWALFilesConfig{
168-
MaxResults: maxParallel,
169+
MaxResults: maxResults,
169170
SkipWALs: []string{baseWalName},
170171
PgDataPath: w.PGDataPath,
171172
},
@@ -174,6 +175,7 @@ func (w WALServiceImplementation) Archive(
174175
// Ensure the requested WAL file is always the first one being
175176
// archived
176177
walFilesList.Ready = append([]string{request.GetSourceFileName()}, walFilesList.Ready...)
178+
contextLogger.Debug("WAL files to archive: %v", "walFilesListReady", walFilesList.Ready)
177179

178180
result := arch.ArchiveList(ctx, walFilesList.ReadyItemsToSlice(), options)
179181
for _, archiverResult := range result {

0 commit comments

Comments
 (0)