From de7b2b8e96aeb7210e59f0ad86a11989c04e141d Mon Sep 17 00:00:00 2001 From: "xikai.wxk" Date: Tue, 23 May 2023 15:27:29 +0800 Subject: [PATCH] feat: more logs for open shard tables --- analytic_engine/src/engine.rs | 6 +++++- catalog/src/table_operator.rs | 35 ++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/analytic_engine/src/engine.rs b/analytic_engine/src/engine.rs index 8990125e4c..b80551ed6b 100644 --- a/analytic_engine/src/engine.rs +++ b/analytic_engine/src/engine.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use async_trait::async_trait; use common_util::error::BoxError; -use log::{error, info}; +use log::{error, info, warn}; use snafu::ResultExt; use table_engine::{ engine::{ @@ -64,6 +64,10 @@ impl TableEngineImpl { table_opt }); + if let Ok(None) = result { + warn!("Try to open a missing table, open request:{request:?}"); + } + open_results.push(result); } diff --git a/catalog/src/table_operator.rs b/catalog/src/table_operator.rs index ae5ab8a6c9..c3d40d82b9 100644 --- a/catalog/src/table_operator.rs +++ b/catalog/src/table_operator.rs @@ -55,8 +55,8 @@ impl TableOperator { // Check and register successful opened table into schema. let mut success_count = 0_u32; - let mut no_table_count = 0_u32; - let mut open_err_count = 0_u32; + let mut missing_table_count = 0_u32; + let mut open_table_errs = Vec::new(); for (schema, open_result) in schemas.into_iter().zip(open_results.into_iter()) { match open_result { @@ -65,31 +65,31 @@ impl TableOperator { success_count += 1; } Ok(None) => { - no_table_count += 1; + missing_table_count += 1; } // Has printed error log for it. - Err(_) => { - open_err_count += 1; + Err(e) => { + open_table_errs.push(e); } } } info!( - "Open shard finish, shard id:{}, cost:{}ms, successful count:{}, no table is opened count:{}, open error count:{}", - shard_id, + "Open shard finish, shard id:{shard_id}, cost:{}ms, success_count:{success_count}, missing_table_count:{missing_table_count}, open_table_errs:{open_table_errs:?}", instant.saturating_elapsed().as_millis(), - success_count, - no_table_count, - open_err_count ); - if no_table_count == 0 && open_err_count == 0 { + if missing_table_count == 0 && open_table_errs.is_empty() { Ok(()) } else { - TableOperatorNoCause { - msg: format!( - "Failed to open shard, some tables open failed, shard id:{shard_id}, no table is opened count:{no_table_count}, open error count:{open_err_count}"), - }.fail() + let msg = format!( + "Failed to open shard, some tables open failed, shard id:{shard_id}, \ + missing_table_count:{missing_table_count}, \ + open_err_count:{}", + open_table_errs.len() + ); + + TableOperatorNoCause { msg }.fail() } } @@ -131,11 +131,8 @@ impl TableOperator { } info!( - "Close shard finished, shard id:{}, cost:{}ms, success_count:{}, close_table_errs:{:?}", - shard_id, + "Close shard finished, shard id:{shard_id}, cost:{}ms, success_count:{success_count}, close_table_errs:{close_table_errs:?}", instant.saturating_elapsed().as_millis(), - success_count, - close_table_errs, ); if close_table_errs.is_empty() {