fix: Accumulation of cancel() funcs enqueueing on pg backend

`cancelFuncs` in the pg backend was intended for gracefully shutting down the backend with Shutdown(). Adding a
new cancel function every time a job is added to a queue isn't of any use, because there is nothing to "cancel" by
cancelling the context unless a job is in progress.

This was effectively a memory leak.
This commit is contained in:
Adriano Caloiaro 2023-09-16 16:53:27 +02:00 committed by Adriano Caloiaro
parent d66905fadd
commit bf2e07cf57

View file

@ -239,10 +239,6 @@ func (p *PgBackend) Enqueue(ctx context.Context, job *jobs.Job) (jobID string, e
}
p.logger.Debug("enqueueing job payload", slog.Any("job_payload", job.Payload))
ctx, cancel := context.WithCancel(ctx)
p.mu.Lock()
p.cancelFuncs = append(p.cancelFuncs, cancel)
p.mu.Unlock()
p.logger.Debug("acquiring new connection from connection pool")
conn, err := p.pool.Acquire(ctx)