注: 最近参加了一个墨天轮举办的openGauss在线学习打卡活动,第一课里提到了gs_ctl命令,于是就查询了gs_ctl的一些其它用法,发现还可以查询线程的堆栈信息,于是查询相关资料并进行了测试。
数据库在运行过程中,可能会出现一些故障,比如数据库夯住,数据库特别慢等情况,此时可通过gs_ctl来查看数据库的堆栈等信息,通过分析这些堆栈信息来排查数据库方面的故障。
一、查询数据库堆栈信息
1.1 查询所有堆栈信息
比如当数据库出现慢,此时还能通过gsql来登陆数据库,此时可通过查询gs_stack查看所有数据库堆栈信息。
[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000 -r
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=# select * from gs_stack();
WARNING: can not get backtrace for thread 140273983616768.
DETAIL: This thread maybe finished, or the signal handler of this thread had not been registed.
WARNING: can not get backtrace for thread 140273789691648.
DETAIL: This thread maybe finished, or the signal handler of this thread had not been registed.
tid | lwtid | stack
-----------------+---------+------------------------------------------------------------------------------------------------------
140280480343168 | 30578 | comm_poll(pollfd*, unsigned long, int) + 0x84 +
| | 0x5622b23bcc07 +
| | PostmasterMain(int, char**) + 0x21d7 +
| | main + 0x3e4 +
| | __libc_start_main + 0xf5 +
| | 0x5622b1a049b7 +
| |
140274864224000 | 30660 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | SysLoggerMain(int) + 0x9a3 +
| | int GaussDbThreadMain<(knl_thread_role)17>(knl_thread_arg*) + 0x293 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274833549056 | 30661 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | AlarmCheckerMain() + 0x2cc +
| | int GaussDbThreadMain<(knl_thread_role)20>(knl_thread_arg*) + 0x28e +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274814088960 | 30663 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | ReaperBackendMain() + 0x1ca +
| | int GaussDbThreadMain<(knl_thread_role)21>(knl_thread_arg*) + 0x27e +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274030339840 | 30788 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | AutoVacLauncherMain() + 0x518 +
| | int GaussDbThreadMain<(knl_thread_role)7>(knl_thread_arg*) + 0x293 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274588186368 | 30693 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | CheckpointerMain() + 0x81d +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)38>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)38>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274571405056 | 30694 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | invalid_buffer_bgwriter_main() + 0x2ad +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)27>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)27>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274520553216 | 30697 | pg_usleep(long) + 0x5d +
| | ckpt_pagewriter_main() + 0xae6 +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274554623744 | 30696 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b242067c +
| | ckpt_pagewriter_main() + 0x82a +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274453968640 | 30701 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b242067c +
| | ckpt_pagewriter_main() + 0x82a +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274486990592 | 30699 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b242067c +
| | ckpt_pagewriter_main() + 0x82a +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274428802816 | 30703 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | PgstatCollectorMain() + 0x2fc +
| | int GaussDbThreadMain<(knl_thread_role)16>(knl_thread_arg*) + 0x2ac +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274503771904 | 30698 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b242067c +
| | ckpt_pagewriter_main() + 0x82a +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274373752576 | 30708 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | PgAuditorMain() + 0x6c5 +
| | int GaussDbThreadMain<(knl_thread_role)15>(knl_thread_arg*) + 0x2ac +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274351142656 | 30709 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | CfsShrinkerMain() + 0x492 +
| | int GaussDbThreadMain<(knl_thread_role)31>(knl_thread_arg*) + 0x2a2 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274334361344 | 30712 | pg_usleep(long) + 0x5d +
| | StatementFlushMain() + 0x5eb +
| | int GaussDbThreadMain<(knl_thread_role)36>(knl_thread_arg*) + 0x2ab +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274158794496 | 30729 | comm_recv(int, void*, unsigned long, int) + 0x6f +
| | secure_read(Port*, void*, unsigned long) + 0x161 +
| | 0x5622b1aca00c +
| | pq_getbyte() + 0x1d +
| | SocketBackend(StringInfoData*) + 0x1a +
| | PostgresMain(int, char**, char const*, char const*) + 0x124f +
| | 0x5622b23afc5e +
| | int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274757990144 | 30787 | WalWriterMain() + 0x646 +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)39>(knl_thread_arg*) + 0x125 +
| | int GaussDbThreadMain<(knl_thread_role)39>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274696713984 | 30745 | PGSemaphoreLock(PGSemaphoreData*, bool) + 0x51 +
| | WalWriterAuxiliaryMain() + 0x4a5 +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)40>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)40>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274118424320 | 30789 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | JobScheduleMain() + 0x446 +
| | int GaussDbThreadMain<(knl_thread_role)9>(knl_thread_arg*) + 0x293 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140274047121152 | 30779 | comm_recv(int, void*, unsigned long, int) + 0x6f +
| | secure_read(Port*, void*, unsigned long) + 0x161 +
| | 0x5622b1aca00c +
| | pq_getbyte() + 0x1d +
| | SocketBackend(StringInfoData*) + 0x1a +
| | PostgresMain(int, char**, char const*, char const*) + 0x124f +
| | 0x5622b23afc5e +
| | int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273983616768 | 30807 | thread 140273983616768 not available +
| |
140274005178112 | 30790 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | UndoLauncherMain() + 0x2e4 +
| | int GaussDbThreadMain<(knl_thread_role)57>(knl_thread_arg*) + 0x292 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273713673984 | 30796 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | TwoPhaseCleanerMain() + 0x83a +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)23>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)23>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273806472960 | 30791 | pg_usleep(long) + 0x5d +
| | GlobalStatsTrackerMain() + 0x295 +
| | int GaussDbThreadMain<(knl_thread_role)60>(knl_thread_arg*) + 0x296 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273772910336 | 30793 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | TxnSnapCapturerMain() + 0x447 +
| | int GaussDbThreadMain<(knl_thread_role)29>(knl_thread_arg*) + 0x2a2 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273789691648 | 30792 | thread 140273789691648 not available +
| |
140273756129024 | 30794 | pg_usleep(long) + 0x5d +
| | PercentileSpace::SubPercentileMain() + 0xb0 +
| | PercentileMain() + 0x230 +
| | int GaussDbThreadMain<(knl_thread_role)28>(knl_thread_arg*) + 0x2ab +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273736742656 | 30795 | pg_usleep(long) + 0x5d +
| | Asp::SubAspWorker() + 0xdb8 +
| | ActiveSessionCollectMain() + 0x3b2 +
| | int GaussDbThreadMain<(knl_thread_role)35>(knl_thread_arg*) + 0x2ab +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273676973824 | 30797 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | FaultMonitorMain() + 0x33c +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)25>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)25>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273479317248 | 30813 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b29c6ce4 +
| | WalSenderMain() + 0xb2b +
| | PostgresMain(int, char**, char const*, char const*) + 0x43f +
| | 0x5622b23afc5e +
| | int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273584699136 | 30799 | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc +
| | 0x5622b28feb41 +
| | undo::UndoRecycleMain() + 0xd01 +
| | int GaussDbAuxiliaryThreadMain<(knl_thread_role)56>(knl_thread_arg*) + 0x120 +
| | int GaussDbThreadMain<(knl_thread_role)56>(knl_thread_arg*) + 0x2ba +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
140273428920064 | 2976218 | gs_signal_send(unsigned long, int, int) + 0x8da +
| | signal_child(unsigned long, int, int) + 0x21 +
| | get_stack_according_to_tid(unsigned long, StringInfoData*) + 0xa3 +
| | save_all_stack_to_tuple(FunctionCallInfoData*) + 0x1cd +
| | gs_stack(FunctionCallInfoData*) + 0x32 +
| | ExecMakeTableFunctionResult(ExprState*, ExprContext*, tupleDesc*, bool, FunctionScanState*) + 0x7d4 +
| | 0x5622b2539efe +
| | ExecScan(ScanState*, TupleTableSlot* (*)(ScanState*), bool (*)(ScanState*, TupleTableSlot*)) + 0x1b8+
| | ExecProcNode(PlanState*) + 0x6e +
| | standard_ExecutorRun(QueryDesc*, ScanDirection, long) + 0x5b8 +
| | 0x5622b235e6f5 +
| | ExecutorRun(QueryDesc*, ScanDirection, long) + 0x9d +
| | 0x5622b2451753 +
| | PortalRun(PortalData*, long, bool, _DestReceiver*, _DestReceiver*, char*) + 0x640 +
| | 0x5622b2446405 +
| | PostgresMain(int, char**, char const*, char const*) + 0x2869 +
| | 0x5622b23afc5e +
| | int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8 +
| | 0x5622b23afce5 +
| | __nptl_deallocate_tsd + 0x1c5 +
| | clone + 0x6d +
| |
(33 rows)
返回当前openGauss所有线程的调用栈:
1.2、查看某个线程堆栈详细信息
如果想查看某个线程的调用栈详细信息,可以通过执行gs_stack(thread_id号)查看详细信息,如下所示:
openGauss=# select gs_stack(thread_id号) # thread_id号及为上面通过select * from gs_stack();查询到的tid号。
-- 如下查询tid为140280480343168栈的详细信息
openGauss=# select gs_stack(140280480343168);
gs_stack
-----------------------------------------------
comm_poll(pollfd*, unsigned long, int) + 0x84+
0x5622b23bcc07 +
PostmasterMain(int, char**) + 0x21d7 +
main + 0x3e4 +
__libc_start_main + 0xf5 +
0x5622b1a049b7 +
(1 row)
二、无法连接库查询堆栈信息
2.1 查询所有堆栈信息
当有些时候,数据库出现故障,无法使用gsql正常连接到库,此时还可以通过gs_ctl命令来查看线程调用栈的信息:
可以通过 gs_ctl -D $PGDATA 命令来查看,如下所示:
[omm@opengauss-node1 ~]$ gs_ctl stack -D /opt/gaussdb/install/data/db1/
[2022-11-24 13:45:01.126][2979546][][gs_ctl]: gs_stack start:
Thread 0 tid<140280480343168> lwtid<30578>
comm_poll(pollfd*, unsigned long, int) + 0x84
0x5622b23bcc07
PostmasterMain(int, char**) + 0x21d7
main + 0x3e4
__libc_start_main + 0xf5
0x5622b1a049b7
Thread 1 tid<140274864224000> lwtid<30660>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
SysLoggerMain(int) + 0x9a3
int GaussDbThreadMain<(knl_thread_role)17>(knl_thread_arg*) + 0x293
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 2 tid<140274833549056> lwtid<30661>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
AlarmCheckerMain() + 0x2cc
int GaussDbThreadMain<(knl_thread_role)20>(knl_thread_arg*) + 0x28e
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 3 tid<140274814088960> lwtid<30663>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
ReaperBackendMain() + 0x1ca
int GaussDbThreadMain<(knl_thread_role)21>(knl_thread_arg*) + 0x27e
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 4 tid<140274030339840> lwtid<30788>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
AutoVacLauncherMain() + 0x518
int GaussDbThreadMain<(knl_thread_role)7>(knl_thread_arg*) + 0x293
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 5 tid<140274588186368> lwtid<30693>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
CheckpointerMain() + 0x81d
int GaussDbAuxiliaryThreadMain<(knl_thread_role)38>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)38>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 6 tid<140274571405056> lwtid<30694>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
invalid_buffer_bgwriter_main() + 0x2ad
int GaussDbAuxiliaryThreadMain<(knl_thread_role)27>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)27>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 7 tid<140274520553216> lwtid<30697>
pg_usleep(long) + 0x5d
ckpt_pagewriter_main() + 0xae6
int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 8 tid<140274554623744> lwtid<30696>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b242067c
ckpt_pagewriter_main() + 0x82a
int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 9 tid<140274453968640> lwtid<30701>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b242067c
ckpt_pagewriter_main() + 0x82a
int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 10 tid<140274486990592> lwtid<30699>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b242067c
ckpt_pagewriter_main() + 0x82a
int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 11 tid<140274428802816> lwtid<30703>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
PgstatCollectorMain() + 0x2fc
int GaussDbThreadMain<(knl_thread_role)16>(knl_thread_arg*) + 0x2ac
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 12 tid<140274503771904> lwtid<30698>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b242067c
ckpt_pagewriter_main() + 0x82a
int GaussDbAuxiliaryThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)46>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 13 tid<140274373752576> lwtid<30708>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
PgAuditorMain() + 0x6c5
int GaussDbThreadMain<(knl_thread_role)15>(knl_thread_arg*) + 0x2ac
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 14 tid<140274351142656> lwtid<30709>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
CfsShrinkerMain() + 0x492
int GaussDbThreadMain<(knl_thread_role)31>(knl_thread_arg*) + 0x2a2
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 15 tid<140274334361344> lwtid<30712>
pg_usleep(long) + 0x5d
StatementFlushMain() + 0x5eb
int GaussDbThreadMain<(knl_thread_role)36>(knl_thread_arg*) + 0x2ab
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 16 tid<140274158794496> lwtid<30729>
comm_recv(int, void*, unsigned long, int) + 0x6f
secure_read(Port*, void*, unsigned long) + 0x161
0x5622b1aca00c
pq_getbyte() + 0x1d
SocketBackend(StringInfoData*) + 0x1a
PostgresMain(int, char**, char const*, char const*) + 0x124f
0x5622b23afc5e
int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 17 tid<140274757990144> lwtid<30787>
WalWriterMain() + 0x646
int GaussDbAuxiliaryThreadMain<(knl_thread_role)39>(knl_thread_arg*) + 0x125
int GaussDbThreadMain<(knl_thread_role)39>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 18 tid<140274696713984> lwtid<30745>
PGSemaphoreLock(PGSemaphoreData*, bool) + 0x51
WalWriterAuxiliaryMain() + 0x4a5
int GaussDbAuxiliaryThreadMain<(knl_thread_role)40>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)40>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 19 tid<140274118424320> lwtid<30789>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
JobScheduleMain() + 0x446
int GaussDbThreadMain<(knl_thread_role)9>(knl_thread_arg*) + 0x293
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 20 tid<140274047121152> lwtid<30779>
comm_recv(int, void*, unsigned long, int) + 0x6f
secure_read(Port*, void*, unsigned long) + 0x161
0x5622b1aca00c
pq_getbyte() + 0x1d
SocketBackend(StringInfoData*) + 0x1a
PostgresMain(int, char**, char const*, char const*) + 0x124f
0x5622b23afc5e
int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 21 tid<140273983616768> lwtid<30807>
thread 140273983616768 not available
Thread 22 tid<140274005178112> lwtid<30790>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
UndoLauncherMain() + 0x2e4
int GaussDbThreadMain<(knl_thread_role)57>(knl_thread_arg*) + 0x292
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 23 tid<140273713673984> lwtid<30796>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
TwoPhaseCleanerMain() + 0x83a
int GaussDbAuxiliaryThreadMain<(knl_thread_role)23>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)23>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 24 tid<140273806472960> lwtid<30791>
pg_usleep(long) + 0x5d
GlobalStatsTrackerMain() + 0x295
int GaussDbThreadMain<(knl_thread_role)60>(knl_thread_arg*) + 0x296
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 25 tid<140273772910336> lwtid<30793>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
TxnSnapCapturerMain() + 0x447
int GaussDbThreadMain<(knl_thread_role)29>(knl_thread_arg*) + 0x2a2
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 26 tid<140273789691648> lwtid<30792>
thread 140273789691648 not available
Thread 27 tid<140273756129024> lwtid<30794>
pg_usleep(long) + 0x5d
PercentileSpace::SubPercentileMain() + 0xb0
PercentileMain() + 0x230
int GaussDbThreadMain<(knl_thread_role)28>(knl_thread_arg*) + 0x2ab
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 28 tid<140273736742656> lwtid<30795>
pg_usleep(long) + 0x5d
Asp::SubAspWorker() + 0xdb8
ActiveSessionCollectMain() + 0x3b2
int GaussDbThreadMain<(knl_thread_role)35>(knl_thread_arg*) + 0x2ab
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 29 tid<140273676973824> lwtid<30797>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
FaultMonitorMain() + 0x33c
int GaussDbAuxiliaryThreadMain<(knl_thread_role)25>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)25>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 30 tid<140273479317248> lwtid<30813>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b29c6ce4
WalSenderMain() + 0xb2b
PostgresMain(int, char**, char const*, char const*) + 0x43f
0x5622b23afc5e
int GaussDbThreadMain<(knl_thread_role)1>(knl_thread_arg*) + 0x2f8
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 31 tid<140273584699136> lwtid<30799>
WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x1dc
0x5622b28feb41
undo::UndoRecycleMain() + 0xd01
int GaussDbAuxiliaryThreadMain<(knl_thread_role)56>(knl_thread_arg*) + 0x120
int GaussDbThreadMain<(knl_thread_role)56>(knl_thread_arg*) + 0x2ba
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
Thread 32 tid<140273428920064> lwtid<2979547>
gs_signal_send(unsigned long, int, int) + 0x8da
signal_child(unsigned long, int, int) + 0x21
get_stack_according_to_tid(unsigned long, StringInfoData*) + 0xa3
get_stack_according_to_lwtid(int, StringInfoData*) + 0xe6
get_stack_and_write_result() + 0xdc
stack_perf_main() + 0x1af
int GaussDbThreadMain<(knl_thread_role)67>(knl_thread_arg*) + 0x2ab
0x5622b23afce5
__nptl_deallocate_tsd + 0x1c5
clone + 0x6d
[2022-11-24 13:45:01.127][2979546][][gs_ctl]: gs_stack finished!
2.2、查询某个堆栈详细信息
假如只想查看某一个线程的调用栈信息,可以通过gs_ctl的如下命令来查看:
gs_ctl stack -D $PGDATA -I lwtid号 来查看
注意:$PGDATA 后跟的 -I是 i的大些字母,lwtid 是通过上述gs_ctl stack -D查看到的 lwtid号。
如下所示:
[omm@opengauss-node1 ~]$ gs_ctl stack -D /opt/gaussdb/install/data/db1/ -I 30578
[2022-11-24 13:47:48.430][2980592][][gs_ctl]: gs_stack start:
tid<140280480343168> lwtid<30578>
comm_poll(pollfd*, unsigned long, int) + 0x84
0x5622b23bcc07
PostmasterMain(int, char**) + 0x21d7
main + 0x3e4
__libc_start_main + 0xf5
0x5622b1a049b7
[2022-11-24 13:47:48.431][2980592][][gs_ctl]: gs_stack finished!
三、总结
以上只是查询了相关堆栈信息,这还不够,更重要的是通过查询到的堆栈信息去分析相关问题原因,提出解决办法。
对于gs_ctl和stack的相关知识,我还要再多加强学习。
最后修改时间:2022-11-29 09:28:59
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




