Skip to content

Commit

Permalink
Merge pull request #8388 from TszKitLo40/open-files-limit
Browse files Browse the repository at this point in the history
feat(query): get the system open file limits and set
  • Loading branch information
mergify[bot] authored Oct 26, 2022
2 parents d180992 + 5ed1855 commit 2430726
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/binaries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ databend-query = { path = "../query/service" }
# Crates.io dependencies
anyhow = { workspace = true }
clap = { workspace = true }
limits-rs = "0.1.0"
openraft = { workspace = true }
sentry = "0.27.0"
serde = { workspace = true }
Expand Down
24 changes: 24 additions & 0 deletions src/binaries/query/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ 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 tracing::info;
use tracing::warn;

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

#[cfg(not(target_os = "macos"))]
check_max_open_files();

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

Expand Down Expand Up @@ -251,3 +256,22 @@ fn run_cmd(conf: &Config) -> bool {

true
}

#[cfg(not(target_os = "macos"))]
fn check_max_open_files() {
let limits = match get_own_limits() {
Ok(limits) => limits,
Err(err) => {
warn!("get system limit of databend-query failed: {:?}", err);
return;
}
};
let max_open_files_limit = limits.max_open_files.soft;
if let Some(max_open_files) = max_open_files_limit {
if max_open_files < 65535 {
warn!(
"The open file limit is too low for the databend-query. Please consider increase it by running `ulimit -n 65535`"
);
}
}
}

1 comment on commit 2430726

@vercel
Copy link

@vercel vercel bot commented on 2430726 Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs
databend.vercel.app

Please sign in to comment.