In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Why does listener carry out two sub-processes of fork? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
It is roughly divided into six stages.
one
The client initiates a connection request to the database, and the listener is responsible for responding and accepting
two
Listener process for child process 1
If child process 1 runs for too long, it will cause listener to wait for a long time (other database connections will not be accepted during this period). If child process 1 is abnormal, listener will hang;-- this sentence a lot, and I just extracted it from the relevant data, without experimental basis.
Ps-ef | the process of ppidprocesses displayed by grep tnslsnr is
three
Child process 1 for child process 2, and then the former exits
At this point, listener waits to accept the data of child process 2.
four
Child process 2 executes the system call exec oracle, which becomes oracle server process, which sends its own metadata (such as pid) to listener.
five
Listener sends client data to server procees and then writes to listener.log
Until the listener task is complete, you can move on to the next connection
six
Server process interacts with the client to complete the follow-up work
Question:
Why does listener want to create two fork child processes? can't we use the first child process to call exec oracle directly?
The following is the reply. Individuals have received a lot of education.
This post was last edited by Yong Huang at 08:48 on 2013-6-28.
It's always a good habit to give reference, unless you find all this out completely from your own test.
I've done such test a long time ago. What you described is basically correct. But this
"if child process 1 runs for too long, it will cause listener to wait for a long time (during which no other database connections will be accepted); if child process 1 is abnormal, listener will hang"
Is new to me. I'd like to know the source.
The reason why listener needs to fork twice is related to the requirement of a UNIX daemon. The best answer is here:
Http://stackoverflow.com/questio... N-creating-a-daemon
Basically, if it forked only once, the server (shadow) process would still have a parent i.e. The tnslsnr process instead of init (pid 1). Forking twice, after the first child exits, the second child will definitely become an orphan and then init becomes its parent.
You may ask why bother to make sure the server process is a daemon. I think the answer is just that Oracle wants to make sure the server process is independent of the listener, so if the listener dies, existing server processes continue to function because they're immune from signals that will be sent to the listener.
Freas
Published on 2013-6-29 00:57:21 | look at the author only
Yong Huang was published on 2013-6-28 22:46
It's always a good habit to give reference, unless you find all this out completely from your own te...
What are the reasons that lead to the process of paralysis?
It is generally believed that after the parent process fork, the wait () function will be called to wait for the end of the child process, and the parent process will get the information about the end of the child process (the child process itself calls exit ()) before the operating system kernel completely releases all the information of a process.
There are two anomalies here. 1. The parent process does not call wait, which results in a dead process. 2. For some reasons, the parent process exits before the child process, and the child process becomes an orphan process and is adopted by init. When the child process exits by calling exit, it becomes a dead process and is disposed of by init.
The double fork strategy adopted by Oracle is similar to the second point, but Oracle is more pessimistic, thinking that the parent process (listener) is bound to be abnormal, so it directly kills the child process out of the first fork by hand (exit after fork), forcing the fork2 to become an orphan process.
As to why Oracle thinks this way, there is no way to know that there may be comments in the source code of Oracle. But it is doubtful whether the idea is scientific or state-of-the-art.
Personal guess, 10 to 20 years ago, the operating system kernel may not be as stable and robust as it is now, and the situation of zombie processes must be taken into account, so make the strategy of double fork.
However, double fork is caused by its side effects.
First of all, a process is a very complex (resource-consuming) component of the kernel.
To generate a process, you need at least four elements:
1. Task_struct structure object.
2. Process private address space.
3. Kernel state stack.
4. Executable code.
When calling a fork process, these resources need to be generated before the process can be generated. When exit (precisely after the parent process wait returns or the data structure of the zombie process is reclaimed), these resources are released. These processes involve traversal of a large number of data structures and locking (spinlock under smp).
And Oracle has adopted a pessimistic and violent strategy, no matter three, seven or twenty-one, fork and exit, but in fact, nothing has been done in this fork1 process. Suppose it is an oltp system, suppose its concurrency is a little larger, for example, thousands of connections per second, the operating system only Oracle will fork 2k times, exit at least 1k times, this resource consumption will be large.
Yong
Why Oracle thinks so, there is no way to know
Didn't you already answer this question? Oracle is pessimistic and thinks that the listener is bound to be abnormal. In case the listener crashes, the server process must be protected from crashing. Although I think it's possible to program the child to not receive any signal delivered to the parent (tnslsnr), it's safer to just fork one more time and let the first child exit.
I haven't checked 12c. But I think somebody says beginning with 12c, Oracle on UNIX/Linux adopts the thread model as on Windows. Hope somebody can check.
Freas
1. Oracle uses doule fork mainly to prevent the listener from being crash when the child process exits, and there is no solution for the child process to become a dead process. As for "in case the listener crashes, the server process must be protected from crashing", the parent process crash, the child process can still run normally, but after the child process calls exit, it will become a dead process.
2. "> why Oracle thinks so, there is no way to know.
Didn't you already answer this question? Oracle is pessimistic and thinks that the listener is bound to be abnormal. "I'm just guessing from a technical level, and, in the above guess, double fork's approach, as a network treatment of server, does more harm than good on July 27th, 2013.
3. I personally think that this way of double fork is more designed from the management of DBA. Because Oracle provides the start/stop/restart interface for listener. If you do not use the double fork approach, once listener stop, all server process will inevitably become orphan processes (at this time, server process may be performing complex transaction, the risk is too high), and server process should not be affected by the running status of listener during "formal work", so directly take the initiative to do this risky operation at the very beginning and take control.
This is the answer to the question about why listener should carry out the two sub-processes of fork. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.