Skip to content

Commit

Permalink
refactor: replace info logs with debug logs in region server (#4829)
Browse files Browse the repository at this point in the history
* refactor: replace info logs with debug logs in region server

Signed-off-by: Ruihang Xia <[email protected]>

* fix: update error handling for closing and opening nonexistent regions

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Oct 14, 2024
1 parent 06e565d commit b61a388
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/datanode/src/region_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use common_recordbatch::SendableRecordBatchStream;
use common_runtime::Runtime;
use common_telemetry::tracing::{self, info_span};
use common_telemetry::tracing_context::{FutureExt, TracingContext};
use common_telemetry::{error, info, warn};
use common_telemetry::{debug, error, info, warn};
use dashmap::DashMap;
use datafusion::datasource::{provider_as_source, TableProvider};
use datafusion::error::Result as DfResult;
Expand Down Expand Up @@ -893,7 +893,7 @@ impl RegionServerInner {
for region in logical_regions {
self.region_map
.insert(region, RegionEngineWithStatus::Ready(engine.clone()));
info!("Logical region {} is registered!", region);
debug!("Logical region {} is registered!", region);
}
Ok(())
}
Expand Down Expand Up @@ -935,17 +935,19 @@ impl RegionServerInner {
.iter()
.map(|x| (*x.key(), x.value().clone()))
.collect::<Vec<_>>();
let num_regions = regions.len();

for (region_id, engine) in regions {
let closed = engine
.handle_request(region_id, RegionRequest::Close(RegionCloseRequest {}))
.await;
match closed {
Ok(_) => info!("Region {region_id} is closed"),
Ok(_) => debug!("Region {region_id} is closed"),
Err(e) => warn!("Failed to close region {region_id}, err: {e}"),
}
}
self.region_map.clear();
info!("closed {num_regions} regions");

let engines = self.engines.write().unwrap().drain().collect::<Vec<_>>();
for (engine_name, engine) in engines {
Expand Down
4 changes: 2 additions & 2 deletions src/metric-engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ mod test {
.await
.unwrap();

// close nonexistent region
// close nonexistent region won't report error
let nonexistent_region_id = RegionId::new(12313, 12);
engine
.handle_request(
nonexistent_region_id,
RegionRequest::Close(RegionCloseRequest {}),
)
.await
.unwrap_err();
.unwrap();

// open nonexistent region won't report error
let invalid_open_request = RegionOpenRequest {
Expand Down
6 changes: 4 additions & 2 deletions src/metric-engine/src/engine/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

//! Close a metric region
use common_telemetry::debug;
use snafu::ResultExt;
use store_api::region_engine::RegionEngine;
use store_api::region_request::{AffectedRows, RegionCloseRequest, RegionRequest};
use store_api::storage::RegionId;

use super::MetricEngineInner;
use crate::error::{CloseMitoRegionSnafu, LogicalRegionNotFoundSnafu, Result};
use crate::error::{CloseMitoRegionSnafu, Result};
use crate::metrics::PHYSICAL_REGION_COUNT;
use crate::utils;

Expand Down Expand Up @@ -54,7 +55,8 @@ impl MetricEngineInner {
{
Ok(0)
} else {
Err(LogicalRegionNotFoundSnafu { region_id }.build())
debug!("Closing a non-existent logical region {}", region_id);
Ok(0)
}
}

Expand Down

0 comments on commit b61a388

Please sign in to comment.