datafusion-ballista icon indicating copy to clipboard operation
datafusion-ballista copied to clipboard

Graceful shutdown: Handle `SIGTERM`

Open thinkharderdev opened this issue 3 years ago • 1 comments

Is your feature request related to a problem or challenge? Please describe what you are trying to do. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] (This section helps Arrow developers understand the context and why for this feature, in addition to the what)

Right now the executors will gracefully shutdown (deregister with the executor) in response to a SIGINT:

    let (notify_scheduler, stop_reason) = tokio::select! {
        service_val = check_services(&mut service_handlers) => {
            let msg = format!("executor services stopped with reason {:?}", service_val);
            info!("{:?}", msg);
            (true, msg)
        },
        _ = signal::ctrl_c() => {
             // sometimes OS can not log ??
            let msg = "executor received ctrl-c event.".to_string();
             info!("{:?}", msg);
            (true, msg)
        },
        _ = stop_recv.recv() => {
            (false, "".to_string())
        },
    };

On kubernetes when a pod terminates it will receive a SIGTERM which doesn't appear to be handled so the executor will not gracefully shutdown.

Describe the solution you'd like A clear and concise description of what you want to happen.

Graceful shutdown on unix systems should initiate graceful shutdown on SIGTERM

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

thinkharderdev avatar Sep 23 '22 16:09 thinkharderdev

cc @mingmwang @yahoNanJing

thinkharderdev avatar Sep 23 '22 16:09 thinkharderdev

@thinkharderdev Sorry, I didn't get a chance to test it in a K8s cluster. I will take a look today.

mingmwang avatar Sep 26 '22 02:09 mingmwang

https://github.com/apache/arrow-ballista/pull/278

mingmwang avatar Sep 26 '22 02:09 mingmwang