Skip to content

Commit fcfcb87

Browse files
authored
fix: cancel job contexts in create/update errors (#858)
1 parent 4fb3b98 commit fcfcb87

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/robfig/cron/v3 v3.0.1
99
github.com/stretchr/testify v1.10.0
1010
go.uber.org/goleak v1.3.0
11+
golang.org/x/crypto v0.40.0
1112
)
1213

1314
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
1919
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2020
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
2121
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
22+
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
23+
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
2224
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2325
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
2426
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

scheduler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,16 +736,19 @@ func (s *scheduler) addOrUpdateJob(id uuid.UUID, definition JobDefinition, taskW
736736
}
737737

738738
if err := s.verifyParameterType(taskFunc, tsk); err != nil {
739+
j.cancel()
739740
return nil, err
740741
}
741742

742743
if err := definition.setup(&j, s.location, s.exec.clock.Now()); err != nil {
744+
j.cancel()
743745
return nil, err
744746
}
745747

746748
newJobCtx, newJobCancel := context.WithCancel(context.Background())
747749
select {
748750
case <-s.shutdownCtx.Done():
751+
newJobCancel()
749752
case s.newJobCh <- newJobIn{
750753
ctx: newJobCtx,
751754
cancel: newJobCancel,
@@ -756,6 +759,7 @@ func (s *scheduler) addOrUpdateJob(id uuid.UUID, definition JobDefinition, taskW
756759
select {
757760
case <-newJobCtx.Done():
758761
case <-s.shutdownCtx.Done():
762+
newJobCancel()
759763
}
760764

761765
out := s.jobFromInternalJob(j)

0 commit comments

Comments
 (0)