From adc61957f42a8f7205b0630a9d0a976511551b47 Mon Sep 17 00:00:00 2001 From: Ian Ballou Date: Tue, 26 Sep 2023 10:40:28 -0400 Subject: [PATCH] Fixes #36771 - introduce sqlite timeout tuning (#25) --- lib/smart_proxy_container_gateway/container_gateway.rb | 3 ++- lib/smart_proxy_container_gateway/container_gateway_main.rb | 3 ++- settings.d/container_gateway.yml.example | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/smart_proxy_container_gateway/container_gateway.rb b/lib/smart_proxy_container_gateway/container_gateway.rb index b1a1de3..2d298d1 100644 --- a/lib/smart_proxy_container_gateway/container_gateway.rb +++ b/lib/smart_proxy_container_gateway/container_gateway.rb @@ -7,7 +7,8 @@ class Plugin < ::Proxy::Plugin default_settings :pulp_endpoint => "https://#{`hostname`.strip}", :katello_registry_path => '/v2/', - :sqlite_db_path => '/var/lib/foreman-proxy/smart_proxy_container_gateway.db' + :sqlite_db_path => '/var/lib/foreman-proxy/smart_proxy_container_gateway.db', + :sqlite_timeout => 30_000 # Load defaults that copy values from SETTINGS. This is done as # programmable settings since SETTINGS isn't initialized during plugin diff --git a/lib/smart_proxy_container_gateway/container_gateway_main.rb b/lib/smart_proxy_container_gateway/container_gateway_main.rb index 06a874a..22be2d4 100644 --- a/lib/smart_proxy_container_gateway/container_gateway_main.rb +++ b/lib/smart_proxy_container_gateway/container_gateway_main.rb @@ -174,7 +174,8 @@ def insert_token(username, token, expire_at_string, clear_expired_tokens: true) def initialize_db file_path = Proxy::ContainerGateway::Plugin.settings.sqlite_db_path - conn = Sequel.connect("sqlite://#{file_path}") + sqlite_timeout = Proxy::ContainerGateway::Plugin.settings.sqlite_timeout + conn = Sequel.connect("sqlite://#{file_path}", timeout: sqlite_timeout) container_gateway_path = $LOAD_PATH.detect { |path| path.include? 'smart_proxy_container_gateway' } begin Sequel::Migrator.check_current(conn, "#{container_gateway_path}/smart_proxy_container_gateway/sequel_migrations") diff --git a/settings.d/container_gateway.yml.example b/settings.d/container_gateway.yml.example index efb729a..0ff1e8a 100644 --- a/settings.d/container_gateway.yml.example +++ b/settings.d/container_gateway.yml.example @@ -6,3 +6,5 @@ :pulp_client_ssl_key: 'RSA private key for the Pulp certificate' :katello_registry_path: 'Katello container registry suffix, e.g., /v2/' :sqlite_db_path: '/var/lib/foreman-proxy/smart_proxy_container_gateway.db' +# Database busy timeout in milliseconds +:sqlite_timeout: 30000