Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/20251112110252.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:bug: `parallelisation` Ensure that execution options are propagated to compound execution group when creating a PriorityExecutionGroup
4 changes: 3 additions & 1 deletion utils/parallelisation/priority_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ func (g *PriorityExecutionGroup[T]) executors() (executor *CompoundExecutionGrou
g.mu.RLock()
defer g.mu.RUnlock()

executor = NewCompoundExecutionGroup(DefaultOptions().MergeWithOptions(Sequential).Options()...)
opts := DefaultOptions().MergeWithOptions(g.options...)
opts.MergeWithOptions(Sequential)
executor = NewCompoundExecutionGroup(opts.Options()...)
for _, key := range slices.Sorted(maps.Keys(g.groups)) {
executor.RegisterExecutor(g.groups[key])
}
Expand Down
28 changes: 28 additions & 0 deletions utils/parallelisation/priority_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,32 @@ func TestPriority(t *testing.T) {
err := priorityGroup.Execute(ctx)
errortest.AssertError(t, err, commonerrors.ErrTimeout)
})

t.Run("stop on first error propagates properly across priorities", func(t *testing.T) {
defer goleak.VerifyNone(t)

var lowerPriorityCalled, samePriorityCalledAfter atomic.Bool

priorityGroup := NewPriorityExecutionGroup(Sequential, StopOnFirstError)

priorityGroup.RegisterFunctionWithPriority(0, testExecutorFunc(func(ctx context.Context) (err error) {
err = commonerrors.ErrConflict
return
}))

priorityGroup.RegisterFunctionWithPriority(0, testExecutorFunc(func(ctx context.Context) (err error) {
samePriorityCalledAfter.Store(true)
return
}))

priorityGroup.RegisterFunctionWithPriority(1, testExecutorFunc(func(ctx context.Context) (err error) {
lowerPriorityCalled.Store(true)
return
}))

err := priorityGroup.Execute(context.Background())
errortest.AssertError(t, err, commonerrors.ErrConflict)
assert.False(t, samePriorityCalledAfter.Load())
assert.False(t, lowerPriorityCalled.Load())
})
}
Loading