[Maria-developers] In daemon plugin, THD problem.
Hi, Sergei! I'm writing daemon plugin . I hava a problem and don't find soultion yet. There is my code as below. ex)plugin.cc ----------------------------------------------------- pthread_handler_t monm_monitor(void *p) { .... THD* thd; thd = new THD; thd->thread_stack= (char*) &thd; tables.init_one_table("performance_schema", 18, "events_statements_current", 25, "events_statements_current", TL_READ); open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT); ..... } static int monm_plugin_init(void *p __attribute__ ((unused))) { ... pthread_create(&mon_thread, &attr, monm_monitor,(void *) ctx)!= 0) .... } ------------------------------------------------------------- In monm_monitor function, THD* thd cause server crash. so I examined coredump. #6 0x0000000000598752 in THD::THD (this=0x7f9b64000930, is_wsrep_applier=false) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_class.cc:1015 I don't know the reason of crash. What I just want to is read events_statements_current's row by using internal interface in a daemon plugin. Is there a another way ? let me know the solution. Regards, Kyungnam. 김경남 부책임연구원 솔루션사업본부 정보기술 연구원 신기술개발팀 02-2099-6177 / 010-2208-3006 _____ 상기 메시지와 첨부화일 내에는 비밀정보가 포함되어 있을 수 있으며, 지정된 수신자에 한하여 조회 및 사용될 수 있습니다. 만약 송신자의 실수로 인하여 상기 메시지를 수신하였다면, 송신자에게 메시지를 반송해 주시고, 원본 메시지와 모든 사본을 폐기해 주시기 바랍니다. 상기 메시지의 전체 또는 일부에 대해 무단 열람, 사용, 공개, 배포하는 것은 금지되어 있습니다.(주)LG CNS. This message and its attachments may contain confidential information, and they are intended to be viewed or used by only the individuals specified in the message. If you have received this message in an error from the sender, please contact the sender immediately to notify the error and delete all of the message and its copies. It is prohibited to view, use, make public and/or distribute part or whole of this message without written permission.
Hi, 김경남! On Mar 26, 김경남 wrote:
Hi, Sergei!
I'm writing daemon plugin . I hava a problem and don't find soultion yet.
In monm_monitor function,
THD* thd cause server crash. so I examined coredump.
#6 0x0000000000598752 in THD::THD (this=0x7f9b64000930, is_wsrep_applier=false) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_class.cc:1015
I don't know the reason of crash.
Neither do I. What MariaDB version do you use? 10.1.2? 10.1.3? I don't see how it could've crashed on that line. Please, show the complete stack trace ('bt' command) and lines around sql_class.cc:1015. Regards, Sergei
Hi,Sergei ! Thanks for the reply and your help. I'll tell you my problem in detail. As I mentioned my last letter, I'm develping mariadb monitoring tool as a daemon plugin type. Source version is 10.1.3-MariaDB-wsrep-debug-log. When I run install plugin command, server crashed. So for test, I removed comment line by line. Here is source. --------- source ------------------------------------------------------------ pthread_handler_t monm_monitor(void *p) { DBUG_ENTER("monm_plugin_test"); ... THD* thd; thd = new THD; --> at this point, error occurred. //thd->thread_stack= (char*) &thd; //thd->store_globals(); //tables.init_one_table("performance_schema", 18, "events_statements_current", 25, "events_statements_current", TL_READ); //open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT); while(1) { ... } } ------------------------------------------------------------------------ --------- At that time, error messag is below, ------------------------------------------------------------------------ --------- Trying to get some variables. Some pointers may be invalid and cause the dump to abort. Query (0x0): Connection ID (thread ID): 0 Status: NOT_KILLED Here is gdb bt result. ------------------------------------------------------------------------ --------- #0 0x000000385cc0c8ac in pthread_kill () from /lib64/libpthread.so.0 #1 0x0000000000c4a270 in my_write_core (sig=11) at /home/windfree/workspace/ws-mariadb/maria-mon/mysys/stacktrace.c:457 #2 0x0000000000754053 in handle_fatal_signal (sig=11) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/signal_handler.cc:266 #3 <signal handler called> #4 my_thread_name () at /home/windfree/workspace/ws-mariadb/maria-mon/mysys/my_thr_init.c:416 #5 0x0000000000c56574 in wt_thd_lazy_init (thd=0x7fc3a8003a90, ds=0x7fc3a80012e8, ts=0x7fc3a80012e0, dl=0x7fc3a80012f8, tl=0x7fc3a80012f0) at /home/windfree/workspace/ws-mariadb/maria-mon/mysys/waiting_threads.c:51 1 #6 0x0000000000598752 in THD::THD (this=0x7fc3a8000930, is_wsrep_applier=false) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_class.cc:1015 #7 0x00007fc3f7851205 in monm_monitor (p=<value optimized out>) at /home/windfree/workspace/ws-mariadb/maria-mon/plugin/monm/monm_plugin_in fo.cc:70 #8 0x000000385cc079d1 in start_thread () from /lib64/libpthread.so.0 #9 0x000000385c4e88fd in clone () from /lib64/libc.so.6 ------------------------------------------------------------------------ ------------------------------------ In addition, I moved that source line to init function as below. And for test, I removed comment line by line. At this time, An error occurred at another line. When I removed comment of source line (thd->store_globals()) and run install plugin command, server crashed . ----- source ---------------------------------------------------------------------- static int monm_plugin_init(void *p __attribute__ ((unused))) { ... thd = new THD; thd->thread_stack= (char*) &thd; thd->store_globals(); // --> at this point, error occurred //tables.init_one_table("performance_schema", 18, "events_statements_current", 25, "events_statements_current", TL_READ); //open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT); ... ... } ------------------------------------------------------------------------ --------- At that time, error messag is below, ------------------------------------------------------------------------ --------- Trying to get some variables. Some pointers may be invalid and cause the dump to abort. Query (0x0): Connection ID (thread ID): 0 Status: NOT_KILLED Here is gdb bt result. ------------------------------------------------------------------------ --------- #0 0x000000385cc0c8ac in pthread_kill () from /lib64/libpthread.so.0 #1 0x0000000000c4a270 in my_write_core (sig=6) at /home/windfree/workspace/ws-mariadb/maria-mon/mysys/stacktrace.c:457 #2 0x0000000000754053 in handle_fatal_signal (sig=6) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/signal_handler.cc:266 #3 <signal handler called> #4 0x000000385c432625 in raise () from /lib64/libc.so.6 #5 0x000000385c433e05 in abort () from /lib64/libc.so.6 #6 0x000000385c42b74e in __assert_fail_base () from /lib64/libc.so.6 #7 0x000000385c42b810 in __assert_fail () from /lib64/libc.so.6 #8 0x00000000007584a2 in handler::ha_thd (this=0x7f91e4023f18) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/handler.cc:2453 #9 0x000000000075eaf7 in mark_trx_read_write (this=0x7f91e4023f18, buf=0x7f91e4014cf8 "\004monm") at /home/windfree/workspace/ws-mariadb/maria-mon/sql/handler.cc:3929 #10 handler::ha_write_row (this=0x7f91e4023f18, buf=0x7f91e4014cf8 "\004monm") at /home/windfree/workspace/ws-mariadb/maria-mon/sql/handler.cc:5852 #11 0x00000000005d53b0 in finalize_install (thd=0x47ecad0, table=0x7f91e40140d0, name=0x47f12f0, argc=0x7f923c3dcc3c, argv=<value optimized out>) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_plugin.cc:2077 #12 0x00000000005d76ba in mysql_install_plugin (thd=0x47ecad0, name=0x47f12f0, dl_arg=<value optimized out>) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_plugin.cc:2151 #13 0x00000000005cb430 in mysql_execute_command (thd=0x47ecad0) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_parse.cc:5445 #14 0x00000000005cb614 in mysql_parse (thd=0x47ecad0, rawbuf=0x7f91e40033c8 "install plugin monm soname 'libmonm.so'", length=<value optimized out>, parser_state=0x7f923c3de740) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_parse.cc:7141 #15 0x00000000005ccb1a in dispatch_command (command=COM_QUERY, thd=0x47ecad0, packet=<value optimized out>, packet_length=39) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_parse.cc:1462 #16 0x00000000005ceaeb in do_command (thd=0x47ecad0) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_parse.cc:1092 #17 0x000000000069c8d7 in do_handle_one_connection (thd_arg=<value optimized out>) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_connect.cc:1347 #18 0x000000000069cab3 in handle_one_connection (arg=0x47ecad0) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_connect.cc:1258 #19 0x0000000000c0b44a in pfs_spawn_thread (arg=0x47f6900) at /home/windfree/workspace/ws-mariadb/maria-mon/storage/perfschema/pfs.cc: 1860 #20 0x000000385cc079d1 in start_thread () from /lib64/libpthread.so.0 #21 0x000000385c4e88fd in clone () from /lib64/libc.so.6 ------------------------------------------------------------------------ ---------------- I don't know the reason of this error. Regards, Kyungnam. ----------------------------Original Message---------------------------- From: Sergei Golubchik(serg@mariadb.org) To: 김경남/부책임연구원/신기술개발팀 Cc: community list[maria-developers@lists.launchpad.net] Date: 2015.03.27 01:33 Subject: Re: In daemon plugin, THD problem. Hi, 김경남! On Mar 26, 김경남 wrote:
Hi, Sergei!
I'm writing daemon plugin . I hava a problem and don't find soultion yet.
In monm_monitor function,
THD* thd cause server crash. so I examined coredump.
#6 0x0000000000598752 in THD::THD (this=0x7f9b64000930, is_wsrep_applier=false) at /home/windfree/workspace/ws-mariadb/maria-mon/sql/sql_class.cc:1015
I don't know the reason of crash.
Neither do I. What MariaDB version do you use? 10.1.2? 10.1.3? I don't see how it could've crashed on that line. Please, show the complete stack trace ('bt' command) and lines around sql_class.cc:1015. Regards, Sergei _____ 상기 메시지와 첨부화일 내에는 비밀정보가 포함되어 있을 수 있으며, 지정된 수신자에 한하여 조회 및 사용될 수 있습니다. 만약 송신자의 실수로 인하여 상기 메시지를 수신하였다면, 송신자에게 메시지를 반송해 주시고, 원본 메시지와 모든 사본을 폐기해 주시기 바랍니다. 상기 메시지의 전체 또는 일부에 대해 무단 열람, 사용, 공개, 배포하는 것은 금지되어 있습니다.(주)LG CNS. This message and its attachments may contain confidential information, and they are intended to be viewed or used by only the individuals specified in the message. If you have received this message in an error from the sender, please contact the sender immediately to notify the error and delete all of the message and its copies. It is prohibited to view, use, make public and/or distribute part or whole of this message without written permission.
participants (2)
-
Sergei Golubchik
-
김경남