Skip to content

Http Service Fail to Start #833

@Flyangz

Description

@Flyangz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions