From befb1c6fb7eda7db0577ff01fcb38e1c3b1b1c21 Mon Sep 17 00:00:00 2001 From: KirIgor Date: Mon, 12 Jan 2026 15:28:19 +0600 Subject: [PATCH 1/3] ch optimize table add timeout --- Gemfile.lock | 2 +- lib/umbrellio_utils/click_house.rb | 4 +++- lib/umbrellio_utils/version.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 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/click_house.rb b/lib/umbrellio_utils/click_house.rb index 00692fc..f8ea7bc 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(5.minutes) 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 From 80baa239ccd40438c4fdf6c303feff64ccbd4787 Mon Sep 17 00:00:00 2001 From: KirIgor Date: Mon, 12 Jan 2026 16:28:28 +0600 Subject: [PATCH 2/3] mv timeout to config --- lib/umbrellio_utils.rb | 3 ++- lib/umbrellio_utils/click_house.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 f8ea7bc..a70e7f4 100644 --- a/lib/umbrellio_utils/click_house.rb +++ b/lib/umbrellio_utils/click_house.rb @@ -53,7 +53,7 @@ def count(dataset) end def optimize_table!(table_name, db_name: self.db_name) - Timeout.timeout(5.minutes) do + Timeout.timeout(UmbrellioUtils.config.ch_optimize_timeout) do execute("OPTIMIZE TABLE #{db_name}.#{table_name} ON CLUSTER click_cluster FINAL") end end From b3821ee7c7c1b506da028208c7623daa7e296f0d Mon Sep 17 00:00:00 2001 From: KirIgor Date: Mon, 12 Jan 2026 16:41:24 +0600 Subject: [PATCH 3/3] fix specs --- spec/umbrellio_utils_spec.rb | 1 + 1 file changed, 1 insertion(+) 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, )