Kill -9 and production application

What problem can cause kill -9 in a production application (more precisely, on Linux)?

I have an application that does some periodic work, it takes a lot of time to stop, and I don't care if some tasks are canceled - the work can be completed by new processes. Can I use kill -9 to stop it immediately, or can it cause serious OS problems?

For example, Unicorn uses it as a normal working procedure:

When your application goes awry, BOFH can just โ€œkill -9โ€ the fluent workflow, without worrying about breaking all clients, only one.

But this article states:

The -9 (or KILL) argument to kill (1) should never be used on Unix systems

PS: I understand that the kill -9 application cannot be processed by the application, but I know that it does not cause any problems for the application-application, I'm just wondering if this can cause some problems at the OS level? shared memory segments active, lingering sockets sounds dangerous to me.

+6
linux operating-system kill unicorn
source share
4 answers

It depends on what kind of application it is.

Something like a database can either lose data (if they do not write all of their data to the constant transaction log at the same time), or take longer to run the next time, or both.

Although Crash-only is a good principle, it currently matches several applications.

For example, the mysql database is not "only crashing", and killing it with kill -9 will lead to a significant startup time (than a clean shutdown), data loss, or both, depending on the settings (and, to some extent, luck).

On the other hand, Cassandra actually encourages the use of kill -9 as a stop mechanism; he does not support anything.

+1
source share

kill -9 prevents the application from disconnecting.

Typically, an application can catch SIGINT/SIGTERM and close it completely (close files, save data, etc.). An application cannot catch SIGKILL (what happens with kill -9 ), and therefore it cannot perform this (extra) cleanup.

The best approach is to use the standard kill , and if the application remains unresponsive, use kill -9 .

+4
source share

kill -9 will not cause any "serious OS problems". But the process will stop immediately, which means that it can leave the data in an odd state.

+2
source share

The KILL signal cannot be captured by the application. If the application is in the middle of writing a complex data structure to disk when you kill it, the structure can only be half written, which will damage the data file. it is usually best to implement some other signal, such as USER1, as a stop signal, as this can be caught and allows the application to close in a controlled manner.

0
source share

All Articles