Skip to content

Commit 7507380

Browse files
JoshVanLartursouza
authored andcommitted
Fix memory leak in queuelock (#33)
Fix memory leak in queue lock whereby deleting jobs on schedulers which do not host the job will grow the queue lock indefinitely. Signed-off-by: joshvanl <[email protected]>
1 parent f56251c commit 7507380

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ func (c *cron) Delete(ctx context.Context, name string) error {
9898
jobKey := c.key.JobKey(name)
9999

100100
c.queueLock.Lock(jobKey)
101-
defer c.queueLock.Unlock(jobKey)
101+
defer c.queueLock.DeleteUnlock(jobKey)
102102

103103
if _, err := c.client.Delete(ctx, jobKey); err != nil {
104104
return err
105105
}
106106

107+
if _, ok := c.queueCache.Load(jobKey); !ok {
108+
return nil
109+
}
110+
107111
c.queueCache.Delete(jobKey)
108112
return c.queue.Dequeue(jobKey)
109113
}

0 commit comments

Comments
 (0)