Bug #93736 I would suggest to add the relevant thread name by pthread_setname_np
Submitted: 25 Dec 2018 17:52 Modified: 22 Jan 2019 8:19
Reporter: Zongzhi Chen (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[25 Dec 2018 17:52] Zongzhi Chen
Description:
I would suggest to add the relevant thread name by pthread_setname_np, when you guys use gdb to debug mysql, you type "thread info", then you get lots thread of named "mysqld". However, when I want to get into the log_writer thread, I need to jump into the thread, and print the stack then I can know the thread.  So I would suggest add thread_name for each thread.

How to repeat:
none

Suggested fix:
I have add the relevant code in my branch, you can get the thread name when you used gdb, looks like these

  28   Thread 0x7fc2e7fff700 (LWP 78917) "log_writer" 0x00007fc4b6882d42 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  27   Thread 0x7fc2e77fe700 (LWP 78918) "log_flusher" 0x00007fc4b6882d42 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  26   Thread 0x7fc2e6ffd700 (LWP 78919) "write_notifier" 0x00007fc4b6882d42 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0

diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 3897500c661..68a39f87173 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2264,6 +2264,14 @@ when waked up either performs a resizing and sleeps again. */
 void buf_resize_thread() {
   my_thread_init();
 
+#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP)
+#ifdef __APPLE__
+  pthread_setname_np("buf_resize");
+#else
+  pthread_setname_np(pthread_self(), "buf_resize");
+#endif
+#endif
+
   while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
     os_event_wait(srv_buf_resize_event);
     os_event_reset(srv_buf_resize_event);
[25 Dec 2018 18:01] Zongzhi Chen
the git diff code

Attachment: diff (application/octet-stream, text), 11.26 KiB.

[2 Jan 2019 8:09] Terje Røsten
Thanks for your report!
[2 Jan 2019 10:36] Frederic Descamps
Hi Chen Zongzhi, 

Thank you for helping MySQL.

In order to submit contributions you must first sign the Oracle Contribution Agreement (OCA).

An OCA can cover an individual person or a company. If your company has already signed an OCA, they should include you in it. If not, you can sign the OCA for yourself.

For additional information please check http://www.oracle.com/technetwork/community/oca-486395.html.
If you have any questions, please contact me.

Best regards,
[8 Jan 2019 11:49] Zongzhi Chen
Hi Frederic Descamps
I have summit the OCA to oracle, but havn't receive reply. 

can you check the mail for me?
[22 Jan 2019 8:19] Zongzhi Chen
Hello, guys
what's going on with this patch now?