Skip to content

Commit

Permalink
apply cr suggs.
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia committed Sep 15, 2023
1 parent 0fc75b8 commit b54debd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/datanode/src/alive_keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl CountdownTask {
"Reset deadline of region {region_id} to approximately {} seconds later",
(deadline - Instant::now()).as_secs_f32(),
);
let _ = self.region_server.set_writable(self.region_id,true);
let _ = self.region_server.set_writable(self.region_id, true);
countdown.set(tokio::time::sleep_until(deadline));
}
// Else the countdown could be either:
Expand Down
31 changes: 13 additions & 18 deletions src/datanode/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ use std::collections::HashMap;
use std::path::Path;
use std::sync::Arc;

use catalog::local::MemoryCatalogManager;
use catalog::remote::MetaKvBackend;
use catalog::kvbackend::MetaKvBackend;
use catalog::memory::MemoryCatalogManager;
use common_base::readable_size::ReadableSize;
use common_base::Plugins;
use common_error::ext::BoxedError;
use common_greptimedb_telemetry::GreptimeDBTelemetryTask;
use common_meta::key::datanode_table::DatanodeTableManager;
use common_meta::key::table_info::TableInfoManager;
use common_meta::kv_backend::KvBackendRef;
pub use common_procedure::options::ProcedureConfig;
use common_runtime::Runtime;
use common_telemetry::info;
use common_telemetry::{error, info};
use futures_util::StreamExt;
use log_store::raft_engine::log_store::RaftEngineLogStore;
use meta_client::client::MetaClient;
Expand All @@ -39,7 +38,7 @@ use query::QueryEngineFactory;
use servers::Mode;
use snafu::{OptionExt, ResultExt};
use store_api::logstore::LogStore;
use store_api::path_utils::{region_dir, WAL_DIR};
use store_api::path_utils::WAL_DIR;
use store_api::region_engine::RegionEngineRef;
use store_api::region_request::{RegionOpenRequest, RegionRequest};
use store_api::storage::RegionId;
Expand Down Expand Up @@ -240,35 +239,31 @@ impl DatanodeBuilder {
regions.push((
RegionId::new(table_value.table_id, region_number),
table_value.engine.clone(),
table_value.region_storage_path.clone(),
));
}
}

info!("going to open {} regions", regions.len());

let table_info_manager = TableInfoManager::new(kv_backend);
for (region_id, engine) in regions {
let Some(table_info) = table_info_manager
.get(region_id.table_id())
.await
.context(GetMetadataSnafu)?
else {
continue;
};
let catalog = table_info.table_info.catalog_name;
let schema = table_info.table_info.schema_name;
for (region_id, engine, region_dir) in regions {
region_server
.handle_request(
region_id,
RegionRequest::Open(RegionOpenRequest {
engine: engine.clone(),
region_dir: region_dir(&catalog, &schema, region_id),
region_dir,
options: HashMap::new(),
}),
)
.await?;
if open_with_writable {
let _ = region_server.set_writable(region_id, true);
if let Err(e) = region_server.set_writable(region_id, true) {
error!(
"failed to set writable for region {region_id}, error: {}",
e
);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/datanode/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ pub enum Error {
source: common_runtime::error::Error,
},

#[snafu(display("Expect KvBackend but not found, location: {}", location))]
#[snafu(display("Expect KvBackend but not found"))]
MissingKvBackend { location: Location },

#[snafu(display("Expect MetaClient but not found, location: {}", location))]
Expand Down

0 comments on commit b54debd

Please sign in to comment.