Live data from Hacker News

When should I not kill -9 a process?

unix.stackexchange.com

61–70 of 85 posts

Re: When should I not kill -9 a process?

#61
post #23

Earlier quoted context omitted.

As a useful variant of this: I have grown accustomed to killing processes that hang with kill -11 (SIGSEGV). This is essentially the same as -9, with the exception that it creates a coredump. Saves a lot of hassle with manually attaching GDB.

It's probably better to use SIGABRT (-6) for that, as it also dumps core and is less likely to be handled by the process (there are valid reasons to handle SIGSEGV and continue in execution)

I never thought of handling SIGSEGV. What would you use it for?

Re: When should I not kill -9 a process?

#62
post #35

I think caution is still key, if you don't know what's going on Slow is Fast here. Several years ago while I was on an airplane flying to spend a nice vacation break with my family my admin partner tried to shutdown a MySQL db the "right way". He logged in and ran a mysqladmin shutdown and waited for a while. Not sure how long he waited but he claimed it was a "long time". Since it felt like there was no response to…

You never were more than a power failure away from that disaster anyway by the looks of it. It wouldn't matter much whether or not the shutdown had started. In cases like these you're essentially playing Russian Roulette with your data, only you're using 5 bullets instead of 1.

Re: When should I not kill -9 a process?

#63
post #52

Earlier quoted context omitted.

This was years ago and trust me it was corrupt. I think there may have been some issues with InnoDB in those days that made it a bit fragile in that situation.

My apologies if it sounded like I was doubting that there was corruption - I was not. I was doubting that merely sending kill -9 to the process was the sole cause of the corruption. More than likely it uncovered the corruption due to having to do recovery against corrupted data.

In the postmortem it seemed that by issuing the shutdown but not waiting for it to complete the database ended up in a strange state that we could never fully recover from.

I guess the moral here is tread lightly and take the time to be informed before you just smack something with a club.

Re: When should I not kill -9 a process?

#64

Earlier quoted context omitted.

+1. Postgres is designed to be resilient to "kill -9" as well as hard power offs. Even if you use durability-sacrificing features like asynchronous commit[1] or unlogged tables[2], the risks are very well-defined and contained to recent transactions and data in that unlogged table, respectively. But even for postgres, you have to be a bit careful. For instance, many disk drives lie about completing the writes and rea…

You, and the OP, are likely mistaken about the cause of the corruption. MySQL, running InnoDB, is ACID compliant. InnoDB takes that durability seriously, and even by hand-tuning the performance factors, it's very hard to put InnoDB in a state where a simple process death, even during shutdown, will corrupt the files on disk. If the database truly corrupted only due to improper shutdown, it was because the double writ…

> double write buffers were disabled on a non-atomic FS

Surely just sending SIGKILL will allow the writes already issued to complete, regardless of the FS type/options? Nobody kicked the plug out of the wall.

Re: When should I not kill -9 a process?

#65

When should I not use signal names in conjunction with kill? Never.

Earlier implementations of the Unix kill command did not allow names, only numbers, so many people (deeply familiar with Unix) know the numbers as well as or better than the names. Plus, it's shorter.

Re: When should I not kill -9 a process?

#66
post #35

I think caution is still key, if you don't know what's going on Slow is Fast here. Several years ago while I was on an airplane flying to spend a nice vacation break with my family my admin partner tried to shutdown a MySQL db the "right way". He logged in and ran a mysqladmin shutdown and waited for a while. Not sure how long he waited but he claimed it was a "long time". Since it felt like there was no response to…

I'm aware it may be an irritating question to answer, and I'd understand if you don't bother, but I have to ask it because I did never understand why people do such things...

Was the extra performance in any way worth it?

Re: When should I not kill -9 a process?

#67
post #23

Earlier quoted context omitted.

It's probably better to use SIGABRT (-6) for that, as it also dumps core and is less likely to be handled by the process (there are valid reasons to handle SIGSEGV and continue in execution)

I never thought of handling SIGSEGV. What would you use it for?

Many applications will try to print their own stack before exiting on SIGSEGV.

Re: When should I not kill -9 a process?

#68
post #65

When should I not use signal names in conjunction with kill? Never.

Earlier implementations of the Unix kill command did not allow names, only numbers, so many people (deeply familiar with Unix) know the numbers as well as or better than the names. Plus, it's shorter.

What earlier implementations? The initial import of /bin/kill into the NetBSD source-tree accepted signal names and that was 21 years and 2 months ago. Same with FreeBSD and their commit message even implies that signal names were allowed in the original 4.4BSD-Lite source.

WRT shorter: Magic numbers don't just suck in programming.

Re: When should I not kill -9 a process?

#69
post #35

I think caution is still key, if you don't know what's going on Slow is Fast here. Several years ago while I was on an airplane flying to spend a nice vacation break with my family my admin partner tried to shutdown a MySQL db the "right way". He logged in and ran a mysqladmin shutdown and waited for a while. Not sure how long he waited but he claimed it was a "long time". Since it felt like there was no response to…

I'm aware it may be an irritating question to answer, and I'd understand if you don't bother, but I have to ask it because I did never understand why people do such things... Was the extra performance in any way worth it?

Here's another question some will surely find irritating: why would you take your laptop and work phone on "vacation"?

Re: When should I not kill -9 a process?

#70
Interesting post and HN comment thread, I'll have to read it in full (or at least the good parts). Anyway, here's a loosely related post that may be of interest, from my blog:

Unix one-liner to kill a hanging Firefox process:

http://jugad2.blogspot.in/2008/09/unix-one-liner-to-kill-han...

It had an interesting thread of comments in which both others and I participated, and at least I learnt some things.

Post reply on HN