Skip to content

Commit

Permalink
feat: more logs for open shard tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiKaiWi committed May 23, 2023
1 parent 904c45a commit de7b2b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
6 changes: 5 additions & 1 deletion analytic_engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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);
}

Expand Down
35 changes: 16 additions & 19 deletions catalog/src/table_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit de7b2b8

Please sign in to comment.