上述日志中,express日志和system日志通常用于排错,当出现数据库服务启动失败、意外报错、服务crash等异常情况,通常可以查看它们来排查错误,遇到无法确定的问题可以将上述日志发回给研发部门分析处理。下面是两个例子:
-
示例一:数据库服务启动失败
这个示例中,由于内存参数设置不合理,造成数据库服务无法启动,参见示例:log\system.log
通过查看日志中的错误信息可以得知错误原因,采取相应的处理手段,如上例,通过调大large heap(超过256MB)便可解决问题。
-
示例二:数据库服务意外crash 在这个数据库意外crash的例子中,system日志会记录下crash时的程序调用堆栈,出现此类情况可将system log发回公司,由相关开发人员排查,这时log中记录的内容类似于core文件的作用,可用于分析产生错误的原因,至少可以获知程序crash的代码点。 参见示例:log\system.log
堆栈分析过程:
Program received signal SIGINT, Interrupt.
…
(gdb) x/i 0xa20516
0xa20516 <_ZN13SorterWrapper12FetchNextRowEb+54>: mov (%rdi),%rax
(gdb) x/i 0x9e636f
0x9e636f <_ZN9TempTable23OrderByAndMaterialize_SERSt6vectorI13SortQueryDescSaIS1_EEyyP12ResultSenderP13SorterWrapper+1593>:
mov %al,-0x201(%rbp)
…
整理好的程序堆栈如下:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x42b09940 (LWP 5722)]
0x0000000000a20516 in SorterWrapper::FetchNextRow(bool) ()
(gdb) bt
#0 0x0000000000a20516 in SorterWrapper::FetchNextRow(bool) ()
#1 0x00000000009e636f in TempTable::OrderByAndMaterialize_S(std::vector<SortQueryDesc, std::allocator >&, unsigned long long, unsigned long long, ResultSender*, SorterWrapper*) ()
#2 0x00000000009e96bb in TempTable::OrderByAndMaterialize(std::vector<SortQueryDesc, std::allocator >&, unsigned long long, unsigned long long, ResultSender*) ()
#3 0x00000000007d2df1 in TempTable::Materialize(bool, THD*, select_result*, ResultSender*) ()
#4 0x0000000000720a3a in ExpressEngine::Execute(THD*, st_lex*, select_result*, st_select_lex_unit*) ()
#5 0x00000000007226b4 in ExpressEngine::HandleSelect(THD*, st_lex*, select_result*&, unsigned long, int&, int&, int&, int) ()
#6 0x000000000095986a in Express_HandleSelect(THD*, st_lex*, select_result*&, unsigned long, int&, int&, int&, int) ()
#7 0x000000000050aa61 in execute_sqlcom_select(THD*, TABLE_LIST*) ()
#8 0x0000000000512f88 in gbase_execute_command(THD*) ()
#9 0x0000000000518b13 in gbase_parse(THD*, char const*, unsigned int, char const**) ()
#10 0x0000000000519ab6 in dispatch_command(enum_server_command, THD*, char*, unsigned int) ()
#11 0x000000000051a42b in do_command(THD*) ()
#12 0x0000000000504a22 in handle_one_connection ()
#13 0x00000000006b9b0d in start_thread ()
#14 0x0000000000c40729 in clone ()