Postgres在启动后,可分别以一下四种形式启动进程:
SubPostmasterMain(--fork)
AuxiliaryProcessMain(--boot)
PostgresMain(--single)
PostmasterMain
PostgreSQL版本使用的多线程启动之后的线程: 10 Thread 0x7fffe478e700 (LWP 42580) "kingbase" (Exiting) 0x00007ffff56c5bf7 in madvise () from /lib64/libc.so.6 9 Thread 0x7fffe498f700 (LWP 42569) "kingbase" 0x00007ffff56c0bcd in poll () from /lib64/libc.so.6 8 Thread 0x7fffe4fa7700 (LWP 42438) "kingbase" 0x00007ffff56c2943 in select () from /lib64/libc.so.6 7 Thread 0x7fffe4b90700 (LWP 42437) "kingbase" 0x00007ffff56c2943 in select () from /lib64/libc.so.6 5 Thread 0x7fffebef6700 (LWP 42327) "kingbase" 0x00007ffff569242d in nanosleep () from /lib64/libc.so.6 4 Thread 0x7fffec0f7700 (LWP 42326) "kingbase" 0x00007ffff56c2943 in select () from /lib64/libc.so.6 3 Thread 0x7fffec514700 (LWP 42323) "kingbase" 0x00007ffff56c2941 in select () from /lib64/libc.so.6 2 Thread 0x7fffec715700 (LWP 42322) "kingbase" 0x00007ffff64c4e91 in sigwait () from /lib64/libpthread.so.0 * 1 Thread 0x7ffff7fd0140 (LWP 42318) "kingbase" 0x00007ffff56c2943 in select () from /lib64/libc.so.6 子线程创建调用#0 ThreadCreate (start=0x8915a1 <MainStarter>, args=0x18ddd70) at kos_signal.c:877 #1 0x0000000000891835 in internal_forkexec (argc=6, argv=0x7fffffffdd80, port=0x7fffffffdae0) at postmaster.c:5116 #2 0x00000000008914ff in postmaster_forkexec (argc=6, argv=0x7fffffffdd80) at postmaster.c:5029 #3 0x0000000000892571 in StartChildProcess (xlop=2) at postmaster.c:5854 #4 0x000000000088d002 in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2376 #5 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 #0 ThreadCreate (start=0x8915a1 <MainStarter>, args=0x18ddd70) at kos_signal.c:877 #1 0x0000000000891835 in internal_forkexec (argc=6, argv=0x7fffffffd540, port=0x7fffffffd2a0) at postmaster.c:5116 #2 0x00000000008914ff in postmaster_forkexec (argc=6, argv=0x7fffffffd540) at postmaster.c:5029 #3 0x0000000000892571 in StartChildProcess (xlop=3) at postmaster.c:5854 #4 0x000000000088f880 in reaper (postgres_signal_arg=17) at postmaster.c:3936 #5 0x000000000087d31f in pg_dispatch_queued_signals () at kos_signal.c:499 #6 0x000000000087c5d1 in sigusr2_handler (postgres_signal_arg=12) at kos_signal.c:148 #7 <signal handler called> #8 0x00007ffff56c2943 in select () from /lib64/libc.so.6 #9 0x000000000088d5d0 in ServerLoop () at postmaster.c:2696 #10 0x000000000088d086 in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2413 #11 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 #0 ThreadCreate (start=0x8915a1 <MainStarter>, args=0x18975a0) at kos_signal.c:877 #1 0x0000000000891835 in internal_forkexec (argc=6, argv=0x7fffffffd540, port=0x7fffffffd2a0) at postmaster.c:5116 #2 0x00000000008914ff in postmaster_forkexec (argc=6, argv=0x7fffffffd540) at postmaster.c:5029 #3 0x0000000000892571 in StartChildProcess (xlop=4) at postmaster.c:5854 #4 0x000000000088f8d3 in reaper (postgres_signal_arg=17) at postmaster.c:3949 #5 0x000000000087d31f in pg_dispatch_queued_signals () at kos_signal.c:499 #6 0x000000000087c5d1 in sigusr2_handler (postgres_signal_arg=12) at kos_signal.c:148 #7 <signal handler called> #8 0x00007ffff56c2943 in select () from /lib64/libc.so.6 #9 0x000000000088d5d0 in ServerLoop () at postmaster.c:2696 #10 0x000000000088d086 in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2413 #11 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 #0 ThreadCreate (start=0x8915a1 <MainStarter>, args=0x18dde70) at kos_signal.c:877 #1 0x0000000000891835 in internal_forkexec (argc=3, argv=0x7fffffffd520, port=0x7fffffffd2b0) at postmaster.c:5116 #2 0x00000000008914ff in postmaster_forkexec (argc=3, argv=0x7fffffffd520) at postmaster.c:5029 #3 0x0000000000886c42 in pgstat_forkexec () at pgstat.c:508 #4 0x0000000000886d01 in pgstat_start () at pgstat.c:568 #5 0x000000000088f915 in reaper (postgres_signal_arg=17) at postmaster.c:3953 #6 0x000000000087d31f in pg_dispatch_queued_signals () at kos_signal.c:499 #7 0x000000000087c5d1 in sigusr2_handler (postgres_signal_arg=12) at kos_signal.c:148 #8 <signal handler called> #9 0x00007ffff56c2943 in select () from /lib64/libc.so.6 #10 0x000000000088d5d0 in ServerLoop () at postmaster.c:2696 #11 0x000000000088d086 in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2413 #12 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 #0 ThreadCreate (start=0x8915a1 <MainStarter>, args=0x186cfd0) at kos_signal.c:877 #1 0x0000000000891835 in internal_forkexec (argc=3, argv=0x7fffffffdbe0, port=0x7fffffffd970) at postmaster.c:5116 #2 0x00000000008914ff in postmaster_forkexec (argc=3, argv=0x7fffffffdbe0) at postmaster.c:5029 #3 0x0000000000882d68 in autovac_forkexec () at autovacuum.c:522 #4 0x0000000000882c1f in autovac_start () at autovacuum.c:459 #5 0x000000000088d8a0 in ServerLoop () at postmaster.c:2845 #6 0x000000000088d086 in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2413 #7 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 共享内存初始化过程- 主线程首次初始化 (gdb) bt #0 InitBufTable (size=11664) at buf_table.c:60 #1 0x00000000008fa224 in StrategyInitialize (init=1 '\001') at freelist.c:342 #2 0x00000000008f1672 in InitBufferPool () at buf_init.c:148 #3 0x000000000091f124 in CreateSharedMemoryAndSemaphores (makePrivate=0 '\000', port=44444) at ipci.c:219 #4 0x000000000088ee5c in reset_shared (port=44444) at postmaster.c:3565 #5 0x000000000088cbcf in PostmasterMain (argc=5, argv=0x186ae60) at postmaster.c:2134 #6 0x00000000007c574f in main (argc=5, argv=0x186ae60) at main.c:288 (gdb) $4 = (HTAB *) 0x18b0f20 - 子线程使用共享内存初始化 #0 InitBufTable (size=11664) at buf_table.c:60 #1 0x00000000008fa224 in StrategyInitialize (init=0 '\000') at freelist.c:342 #2 0x00000000008f1672 in InitBufferPool () at buf_init.c:148 #3 0x000000000091f124 in CreateSharedMemoryAndSemaphores (makePrivate=0 '\000', port=0) at ipci.c:219 #4 0x0000000000891bef in SubPostmasterMain (argc=6, argv=0x18ddd70) at postmaster.c:5388 #5 0x0000000000891644 in MainStarter (params=0x18ddd70) at postmaster.c:5070 #6 0x00007ffff64bddc5 in start_thread () from /lib64/libpthread.so.0 #7 0x00007ffff56cb21d in clone () from /lib64/libc.so.6 $8 = (HTAB *) 0x7fffe0022390 - 子线程使用共享内存初始化 #0 InitBufTable (size=11664) at buf_table.c:60 #1 0x00000000008fa224 in StrategyInitialize (init=0 '\000') at freelist.c:342 #2 0x00000000008f1672 in InitBufferPool () at buf_init.c:148 #3 0x000000000091f124 in CreateSharedMemoryAndSemaphores (makePrivate=0 '\000', port=0) at ipci.c:219 #4 0x0000000000891bef in SubPostmasterMain (argc=6, argv=0x18ddd70) at postmaster.c:5388 #5 0x0000000000891644 in MainStarter (params=0x18ddd70) at postmaster.c:5070 #6 0x00007ffff64bddc5 in start_thread () from /lib64/libpthread.so.0 #7 0x00007ffff56cb21d in clone () from /lib64/libc.so.6 $10 = (HTAB *) 0x7fffe00243a0 - 子线程使用共享内存初始化 #0 InitBufTable (size=11664) at buf_table.c:60 #1 0x00000000008fa224 in StrategyInitialize (init=0 '\000') at freelist.c:342 #2 0x00000000008f1672 in InitBufferPool () at buf_init.c:148 #3 0x000000000091f124 in CreateSharedMemoryAndSemaphores (makePrivate=0 '\000', port=0) at ipci.c:219 #4 0x0000000000891bef in SubPostmasterMain (argc=6, argv=0x18975a0) at postmaster.c:5388 #5 0x0000000000891644 in MainStarter (params=0x18975a0) at postmaster.c:5070 #6 0x00007ffff64bddc5 in start_thread () from /lib64/libpthread.so.0 #7 0x00007ffff56cb21d in clone () from /lib64/libc.so.6 $12 = (HTAB *) 0x7fffd8022390 - 子线程使用共享内存初始化..... (责任编辑:IT) |