In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about the impact of using the linux command to kill postgresql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Using the linux command to kill postgresql on the server of the database, such as kill-9 xxxx, what effect this will have on postgresql? many people have done this before, and why it is so bad.
First of all, we need to understand how postgresql works in linux, system call and fork () system call, where
It's system call.
Postgres 102414 10 08:34? 00:00:00 / usr/local/postgres/bin/postgres-D / pgdata/data
The ones below are fork () sytem call.
Postgres 102415 102414 0 08:34? 00:00:00 postgres: logger
Postgres 102417 102414 0 08:34? 00:00:00 postgres: checkpointer
Postgres 102418 102414 0 08:34? 00:00:00 postgres: background writer
Postgres 102419 102414 0 08:34? 00:00:00 postgres: walwriter
Postgres 102420 102414 0 08:34? 00:00:00 postgres: autovacuum launcher
Postgres 102421 102414 0 08:34? 00:00:00 postgres: archiver
Postgres 102422 102414 0 08:34? 00:00:01 postgres: stats collector
Postgres 102423 102414 0 08:34? 00:00:00 postgres: logical replication launcher
Postgres 102415 102414 0 08:34? 00:00:00 postgres: logger
Postgres 102417 102414 0 08:34? 00:00:00 postgres: checkpointer
Postgres 102418 102414 0 08:34? 00:00:00 postgres: background writer
Postgres 102419 102414 0 08:34? 00:00:00 postgres: walwriter
Postgres 102420 102414 0 08:34? 00:00:00 postgres: autovacuum launcher
Postgres 102421 102414 0 08:34? 00:00:00 postgres: archiver
Postgres 102422 102414 0 08:34? 00:00:01 postgres: stats collector
Postgres 102423 102414 0 08:34? 00:00:00 postgres: logical replication launcher
The above creates a new process by calling fork (). This system call copies the current process and creates a new entry in the process table with many of the same properties as the current process. The newly created process will be a child of the calling process
So the parent process is pid and the word process is ppid
Of course, you can also view the current dependency between the main threads through pstree.
The types of signals for PostgreSQL to call the LINUX operating system are as follows
1 Abrt abnormal termination signal
2 int external interrupt, similar to the result of Ctrl + C
3 quit cleans up running threads directly, and does not clean up temporarily generated files
The command 4 term is the kill command that we are familiar with.
5 hup command to reinitialize the thread
6 user call definition
Let's do a test to see what's wrong with a user connection if we are kill-9.
The following is the log after the user process of kill who is currently connected to the database
If you can't see the picture clearly, I'll stick the key sentence.
WARNING: terminating connection because of crash of another server process
Let's take a breath by comparing the number of child processes in database after the processes connected by kill users.
Well, if you immediately see someone here, there will be a question: how can I kill the user who occupies resources in vain and does not work?
(the answer to the question will be given at the end of the article)
So let's turn it over and see what happens after a user connects to process in kill-9.
1 user's connection process is killed by kill-9 2
2 terminate any other active server processes
3 warning because this action of you will cause other processes on the server postgresql to crash
4 postgresql processes reinitialization of all servers
That is, these words in the journal.
Database system was not properly shut down; automatic recovery in progress
Redo starts at 5/1C000098
Invalid record length at 5/1C000108: wanted 24, got 0
Redo done at 5/1C0000D0
Database system is ready to accept connections
OK here you dare to casually kill-9 user connections, especially hundreds of gigabytes or on T large library, Are you crazy?
So what's the right thing to do?
The pg_terminate_backend command goes to KILL the user's connection in the database.
And will not cause any harm to the database. (see picture above)
So you are still in the process of kill-9 users every day, I suggest you stop.
Thank you for reading! This is the end of this article on "what is the impact of killing postgresql through linux commands". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.