Skip to content

Commit

Permalink
feat(query): get the system open file limits and set
Browse files Browse the repository at this point in the history
  • Loading branch information
TszKitLo40 committed Oct 23, 2022
1 parent b83b0c1 commit 8ed1d16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/binaries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ tokio-stream = "0.1.10"
tonic = "0.8.1"
tracing = "0.1.36"
url = "2.3.1"
limits-rs = "0.1.0"
sysinfo = "0.26.5"

[[bin]]
name = "databend-meta"
Expand Down
14 changes: 14 additions & 0 deletions src/binaries/query/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use databend_query::servers::MySQLHandler;
use databend_query::servers::Server;
use databend_query::servers::ShutdownHandle;
use databend_query::GlobalServices;
use limits_rs::get_own_limits;
use sysinfo::set_open_files_limit;
use tracing::info;
use tracing::warn;

#[databend_main]
async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<()> {
Expand Down Expand Up @@ -73,6 +76,17 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
init_default_metrics_recorder();
set_panic_hook();

let limits = get_own_limits().unwrap();
let max_open_files_soft_limit = limits.max_open_files.soft;
match max_open_files_soft_limit {
Some(limit) => {
if limit < 65535 && set_open_files_limit(65535) {
warn!("Open files limit has been set to {}", 65535);
}
}
None => {}
}

GlobalServices::init(conf.clone()).await?;
let mut shutdown_handle = ShutdownHandle::create()?;

Expand Down

0 comments on commit 8ed1d16

Please sign in to comment.