systemctl stop kumomta.service / systemctl restart kumomta.service hangs

Hello ! When i execute the systemctl stop kumomta.service or systemctl restart kumomta.service command, it hangs for approx 5 minutes before stopping the service, i have seen some similar reports in the Discord, do you have an idea why ? In total i had 2 installation of kumomta on 2 different machines, from my experience it seems that in the beginning everything works fine, but if you start to make several restarts in a row, the issue will show up.

This issue is happening in our testing env, so it has very little load

Logs :

2025-04-01T09:11:06.286099Z  INFO localset-0 kumod::smtp_server: smtp listener on 0.0.0.0:2525 -> stopping
2025-04-01T09:11:06.286188Z  INFO   qmaint-0 kumod::ready_queue: queue_config_maintainer stopping
2025-04-01T09:11:06.287393Z  INFO   qmaint-0 kumod::queue: queue_config_maintainer stopping
2025-04-01T09:15:38.611822Z  INFO       main kumo_server_common::start: Shutdown completed OK!
2025-04-01T09:15:38.626678Z  INFO       main kumod::spool: Shutting down spool
2025-04-01T09:15:38.626987Z  INFO       main kumod::spool: data shutdown completed in 170.949µs
2025-04-01T09:15:38.627003Z  INFO       main kumod::spool: meta shutdown completed in 149.111µs
2025-04-01T09:15:38.627389Z  INFO       main kumod: application logic complete, returning from main

Kcli top at the moment of the stop :

Thank you for your help

Stacktrace:
message.txt (37.1 KB)

Service status while the stop command is hanging :

kumomta.service - KumoMTA SMTP service
     Loaded: loaded (/etc/systemd/system/kumomta.service; enabled; preset: enabled)
     Active: deactivating (stop-sigterm) since Tue 2025-04-01 11:49:59 CEST; 2min 2s ago
   Main PID: 181751 (kumod)
      Tasks: 27 (limit: 19102)
     Memory: 38.6M (peak: 97.3M)
        CPU: 623ms
     CGroup: /system.slice/kumomta.service
             └─181751 /opt/kumomta/sbin/kumod --policy /opt/kumomta/etc/policy/init.lua --user kumod

avril 01 11:49:44 xxxxx systemd[1]: Started kumomta.service - KumoMTA SMTP service.
avril 01 11:49:59 xxxxx systemd[1]: Stopping kumomta.service - KumoMTA SMTP service...

It seems that if kumo has been running for a while (a dozen minutes i’d say), the systemctl stop kumomta.service will be executed almost instantly, but if just after that stop, i start & try to stop the service again, this time the systemctl stop kumomta.service command will hang for 5 minutes

Kumomta may need some time to process the unprocessed data before shutting down safely. May I ask if the sending volume will be large?

Connections are not instantly terminated when restarting or shutting down, they are allowed to complete their timeouts. That is the most typical cause.

It sounds like you have a misconfiguration somewhere. 5 minutes is the systemd timeout so you will probably find that if you trace the journal in debug mode you will see whatever is thrashing around and a final SIGKILL, which should never happen if it is configured correctly.