From b1852dde66b1891b1b15458b37e73645d8da89d2 Mon Sep 17 00:00:00 2001 From: NikitaUnisikhin <92248695+NikitaUnisikhin@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:22:48 +0300 Subject: [PATCH] Shorten the error message in orphaned-objects monrun check (#265) * Added regular pattern for handle errors in orphaned-objects monrun check * Update tests * lint * Refactoring and add spare_pattern * Fix test * Fix * Fix tests * Create consts * Delete SPARE_ERROR_MESSAGE_PATTERN * Fixes * Refactoring, update ch_tools/common/config.py * Update Check Geobase --------- Co-authored-by: Nikita Unisikhin --- ch_tools/common/config.py | 4 ++++ tests/features/monrun.feature | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ch_tools/common/config.py b/ch_tools/common/config.py index cc7d3769..727ec55c 100644 --- a/ch_tools/common/config.py +++ b/ch_tools/common/config.py @@ -84,6 +84,10 @@ "pattern": "\n", "replacement": " ", }, + { + "pattern": r"(Code:\s\d+\.\sDB::Exception:\s).*(\s\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)\s).*", + "replacement": r"\1...\2...", + }, ], }, }, diff --git a/tests/features/monrun.feature b/tests/features/monrun.feature index b96db5f5..2c357256 100644 --- a/tests/features/monrun.feature +++ b/tests/features/monrun.feature @@ -98,7 +98,7 @@ Feature: ch-monitoring tool """ Then we get response contains """ - 1;Unknown error: Code: 156. DB::Exception: Embedded dictionaries were not loaded. + 1;Unknown error: Code: 156. DB::Exception: ... (DICTIONARIES_WAS_NOT_LOADED) """ When we execute command on clickhouse01 """ @@ -513,3 +513,14 @@ Feature: ch-monitoring tool """ 2;ERROR """ + + Scenario: Check clickhouse orphaned objects with long error_msg + When we create file /tmp/object_storage_cleanup_state.json with data "{ \"orphaned_objects_size\": 0, \"error_msg\": \"Code: 27. DB::Exception: Cannot parse: input:: expected '\\\\t' before: 'klg%2D1acvr8hmq0n16qm5%2Edb%2Eyandex%2Enet\\\\ndefault\\\\n6736d483-516a-4892-87d4-084d5c1f6d3c\\\\n': While executing SystemRemoteDataPaths. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 24.8.5.115 (official build)) Query: SELECT obj_path, obj_size FROM _system.listing_objects_from_object_storage AS object_storage LEFT ANTI JOIN remoteSecure('klg-1acvr8hmq0n16qm5.db.yandex.net', system.remote_data_paths) AS object_table ON object_table.remote_path = object_storage.obj_path AND object_table.disk_name = 'object_storage' SETTINGS traverse_shadow_remote_data_paths=1 FORMAT TabSeparated (klg-1acvr8hmq0n16qm5.mdb.yandex.net)\" }" + And we execute command on clickhouse01 + """ + ch-monitoring orphaned-objects --state-local + """ + Then we get response + """ + 2;Code: 27. DB::Exception: ... (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 24.8.5.115 (official build)) ... + """