From 29f297cae722aa9143f8408c5c4ecd240da08e80 Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Mon, 9 Sep 2024 17:19:15 +0200 Subject: [PATCH] Lock the process record before heartbeating To guard against race conditions of the record being deleted precisely then. --- lib/solid_queue/processes/registrable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solid_queue/processes/registrable.rb b/lib/solid_queue/processes/registrable.rb index 9eddf20e..084e8faf 100644 --- a/lib/solid_queue/processes/registrable.rb +++ b/lib/solid_queue/processes/registrable.rb @@ -53,7 +53,7 @@ def stop_heartbeat end def heartbeat - process.reload.heartbeat + process.with_lock(&:heartbeat) rescue ActiveRecord::RecordNotFound self.process = nil wake_up