From 1ce892ab157fd1a4a939940f91beb608b68bdd02 Mon Sep 17 00:00:00 2001 From: Pranav Shridhar Date: Fri, 31 May 2024 07:37:54 +0530 Subject: [PATCH] code cleanup --- backends/sqlite/sqlite_backend.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/sqlite/sqlite_backend.go b/backends/sqlite/sqlite_backend.go index 980e6c6..0bc375b 100644 --- a/backends/sqlite/sqlite_backend.go +++ b/backends/sqlite/sqlite_backend.go @@ -46,7 +46,6 @@ const ( AND status != "processed" AND run_after > datetime("now") ORDER BY run_after ASC` - shutdownJobID = "-1" // job ID announced when triggering a shutdown ) var ( @@ -169,6 +168,7 @@ func (s *SqliteBackend) Enqueue(ctx context.Context, job *jobs.Job) (jobID strin // Rollback is safe to call even if the tx is already closed, so if // the tx commits successfully, this is a no-op defer func(ctx context.Context) { _ = tx.Rollback() }(ctx) // rollback has no effect if the transaction has been committed + jobID, err = s.enqueueJob(ctx, tx, job) if err != nil { s.logger.Error("error enqueueing job", slog.String("queue", job.Queue), slog.Any("error", err)) @@ -733,7 +733,10 @@ func (s *SqliteBackend) Shutdown(ctx context.Context) { } s.cron.Stop() + + s.dbMutex.Lock() s.db.Close() + s.dbMutex.Unlock() s.cancelFuncs = nil s.logger.Debug("shutdown complete")