diff --git a/Gemfile.lock b/Gemfile.lock index 6574b16..21edf7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - umbrellio-utils (1.10.0) + umbrellio-utils (1.10.1) memery (~> 1) GEM diff --git a/lib/umbrellio_utils.rb b/lib/umbrellio_utils.rb index 8b922a3..25044ca 100644 --- a/lib/umbrellio_utils.rb +++ b/lib/umbrellio_utils.rb @@ -16,7 +16,7 @@ def included(othermod) def config synchronize do @@config ||= Struct - .new(:store_table_name, :http_client_name, keyword_init: true) + .new(:store_table_name, :http_client_name, :ch_optimize_timeout, keyword_init: true) .new(**default_settings) end end @@ -38,6 +38,7 @@ def default_settings { store_table_name: :store, http_client_name: :application_httpclient, + ch_optimize_timeout: 5.minutes, } end diff --git a/lib/umbrellio_utils/click_house.rb b/lib/umbrellio_utils/click_house.rb index 00692fc..a70e7f4 100644 --- a/lib/umbrellio_utils/click_house.rb +++ b/lib/umbrellio_utils/click_house.rb @@ -53,7 +53,9 @@ def count(dataset) end def optimize_table!(table_name, db_name: self.db_name) - execute("OPTIMIZE TABLE #{db_name}.#{table_name} ON CLUSTER click_cluster FINAL") + Timeout.timeout(UmbrellioUtils.config.ch_optimize_timeout) do + execute("OPTIMIZE TABLE #{db_name}.#{table_name} ON CLUSTER click_cluster FINAL") + end end def truncate_table!(table_name, db_name: self.db_name) diff --git a/lib/umbrellio_utils/version.rb b/lib/umbrellio_utils/version.rb index 495981b..7dbd65d 100644 --- a/lib/umbrellio_utils/version.rb +++ b/lib/umbrellio_utils/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module UmbrellioUtils - VERSION = "1.10.0" + VERSION = "1.10.1" end diff --git a/spec/umbrellio_utils_spec.rb b/spec/umbrellio_utils_spec.rb index 52b845d..cb6beac 100644 --- a/spec/umbrellio_utils_spec.rb +++ b/spec/umbrellio_utils_spec.rb @@ -7,6 +7,7 @@ it "sets proper default configuration" do expect(described_class.config.to_h).to eq( + ch_optimize_timeout: 5.minutes, store_table_name: :store, http_client_name: :application_httpclient, )