From 20a89d58661a3e8a4b9a3351f7c560ab64d9bd88 Mon Sep 17 00:00:00 2001 From: Seth Grover Date: Fri, 27 Oct 2023 07:13:33 -0600 Subject: [PATCH] work in pgoress for address issues with NetBox database and Logstash's NetBox cache, should fix locking issues (idaholab/Malcolm#259) --- logstash/ruby/netbox_enrich.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/logstash/ruby/netbox_enrich.rb b/logstash/ruby/netbox_enrich.rb index 2d071a970..96e4dc31e 100644 --- a/logstash/ruby/netbox_enrich.rb +++ b/logstash/ruby/netbox_enrich.rb @@ -236,6 +236,7 @@ def filter(event) # make sure the connection to the NetBox API exists and wasn't flagged for reconnect if @netbox_conn.nil? || @netbox_conn_needs_reset + @netbox_conn_lock.release_read_lock @netbox_conn_lock.acquire_write_lock begin if @netbox_conn.nil? || @netbox_conn_needs_reset @@ -254,6 +255,7 @@ def filter(event) end # connection check in write lock ensure @netbox_conn_lock.release_write_lock + @netbox_conn_lock.acquire_read_lock end end # connection check in read lock @@ -723,6 +725,7 @@ def filter(event) end # check if device was created and has ID if _exception_error_connection && !@netbox_conn_resetting + @netbox_conn_lock.release_read_lock @netbox_conn_lock.acquire_write_lock begin if !@netbox_conn_resetting @@ -730,6 +733,7 @@ def filter(event) end ensure @netbox_conn_lock.release_write_lock + @netbox_conn_lock.acquire_read_lock end end ensure