-
Notifications
You must be signed in to change notification settings - Fork 210
Description
Describe the bug
Http service fail to start.
To Reproduce
add the following code to blaze/native-engine/blaze/src/http/mod.rs and run test with cargo test --package blaze --lib http::test::test_http_service -- --exact --nocapture. We will see "Blaze http service started. port: xxxx". But if we exec lsof -i :xxxx, "xxxx" is not used.
#[cfg(test)]
mod test {
use std::thread;
use std::time::Duration;
use datafusion::error::DataFusionError;
use crate::http::{HTTP_SERVICE, HttpService};
#[test]
fn test_http_service() {
let _ = HTTP_SERVICE.get_or_try_init(|| {
eprintln!("initializing http service...");
Ok::<HttpService, DataFusionError>(HttpService::init())
});
loop {
eprintln!("sleep...");
thread::sleep(Duration::from_millis(3000));
}
}
}Expected behavior
Http service start successfully.
Additional context
After debugging, I found the reason is the tokio runtime is out of scope. In the following code, server is created, but it is not referred by any other object. So the server and its tokio runtime which runs the internal http server will be released.
https://github.com/kwai/blaze/blob/6ca415205bec382442aafa1f707b6b018547b438/native-engine/blaze/src/http/mod.rs#L93-L105