![]() ![]() It knows the backend might have corrupted shared memory - because you could've interrupted it half way through writing a page into shm or modifying one, for example - so it terminates and restarts all the other backends when it notices that a backend has suddenly vanished and exited with a non-zero error code. When it comes to PostgreSQL, Pg sees a backed that's terminated by kill -9 as a backed crash. Kill -9 gives the killed process no chance to do any cleanup at all. That's true of Pg and pretty much everything else. It should be your last resort when the process doesn't respond to its normal shutdown requests and a SIGTERM ( kill -15) has had no effect. Kill -9 (ie SIGKILL) should never, ever, ever be your first-choice default. Voretaq7's answer covers the key points, including the correct way to terminate backends but I'd like to add a little more explanation. ![]() With that said, and after further reading, it looks like kill pid without the flags is the preferred way to kill a runaway postgres process, but per other users in the postgres community, it also sounds like postgres has "gotten better" over the years such that kill -9 on an individual query process/thread is no longer a death sentence.Ĭan someone enlighten me on the proper way to kill a runaway postgres process as well as the how disastrous (or benign) using kill -9 is with Postgres these days? Thanks for the insight. I've done this before a handful of times and have not seen any negative side effects. However, one of our developers chewed me out for killing a postgres process with kill -9, saying that it will take down the entire postgres service. This server is running postgres 9.1.3 on SLES 9 SP4. The rest of the system and postgres queries appeared to be unaffected. ![]() This killed the process and the memory freed up as expected. I found the particular process via ps aux | grep postgres and ran kill -9 pid. A postgres SELECT query ran out of control on our DB server and started eating up tons of memory and swap until the server ran out of memory. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |