From 5c968c3f12c87a37915c7d38e616eb20e1610de7 Mon Sep 17 00:00:00 2001
From: Bassam Mansoob <bassam.mansoob@shopify.com>
Date: Wed, 18 Sep 2024 11:07:39 -0400
Subject: [PATCH] remove release_run_lock side-effect if already released

---
 lib/app_profiler/backend/base_backend.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/app_profiler/backend/base_backend.rb b/lib/app_profiler/backend/base_backend.rb
index ca1a20a..81946c9 100644
--- a/lib/app_profiler/backend/base_backend.rb
+++ b/lib/app_profiler/backend/base_backend.rb
@@ -40,7 +40,7 @@ def acquire_run_lock
       end
 
       def release_run_lock
-        self.class.run_lock.unlock
+        self.class.run_lock.unlock if self.class.run_lock.locked?
       rescue ThreadError
         AppProfiler.logger.warn("[AppProfiler] run lock not released as it was never acquired")
       end