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); diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index f88464d071e..1a84aae80c0 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -679,6 +679,14 @@ void buf_dump_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("buf_dump"); +#else + pthread_setname_np(pthread_self(), "buf_dump"); +#endif +#endif + buf_dump_status(STATUS_VERBOSE, "Dumping of buffer pool not started"); buf_load_status(STATUS_VERBOSE, "Loading of buffer pool not started"); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 1b61bc5ed73..9d1e5327ab7 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2957,6 +2957,15 @@ static void buf_flush_page_coordinator_thread(size_t n_page_cleaners) { } #endif /* UNIV_LINUX */ +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("flush_coordinator"); +#else + pthread_setname_np(pthread_self(), "flush_coordinator"); +#endif +#endif + + buf_page_cleaner_is_active = true; /* We start from 1 because the coordinator thread is part of the @@ -3295,6 +3304,14 @@ static void buf_flush_page_cleaner_thread() { } #endif /* UNIV_LINUX */ +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("page_cleaner"); +#else + pthread_setname_np(pthread_self(), "page_cleaner"); +#endif +#endif + for (;;) { os_event_wait(page_cleaner->is_requested); diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 6b623db1349..4454fe9fb8f 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -368,6 +368,14 @@ statistics. */ void dict_stats_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("dict_stats"); +#else + pthread_setname_np(pthread_self(), "dict_stats"); +#endif +#endif + ut_a(!srv_read_only_mode); THD *thd = create_thd(false, true, true, 0); diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index c983eee11af..e3d90065c6f 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2810,6 +2810,14 @@ static void fts_optimize_thread(ib_wqueue_t *wq) { my_thread_init(); ut_ad(!srv_read_only_mode); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("fts_optimize"); +#else + pthread_setname_np(pthread_self(), "fts_optimize"); +#endif +#endif + THD *thd = create_thd(false, true, true, 0); heap = mem_heap_create(sizeof(dict_table_t *) * 64); diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index a0616a82e52..d7b18a266d3 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -457,6 +457,14 @@ void lock_wait_timeout_thread() { ut_ad(!srv_read_only_mode); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("lock_wait_time"); +#else + pthread_setname_np(pthread_self(), "lock_wait_time"); +#endif +#endif + do { srv_slot_t *slot; diff --git a/storage/innobase/log/log0chkp.cc b/storage/innobase/log/log0chkp.cc index 68649121edc..c932c942c8d 100644 --- a/storage/innobase/log/log0chkp.cc +++ b/storage/innobase/log/log0chkp.cc @@ -871,6 +871,14 @@ void log_checkpointer(log_t *log_ptr) { log_t &log = *log_ptr; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("log_checkpointer"); +#else + pthread_setname_np(pthread_self(), "log_checkpointer"); +#endif +#endif + log_checkpointer_mutex_enter(log); while (true) { diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index e12a291a8c9..747aaedcf76 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -760,6 +760,14 @@ pools. */ static void recv_writer_thread() { ut_ad(!srv_read_only_mode); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("recv_writer"); +#else + pthread_setname_np(pthread_self(), "recv_writer"); +#endif +#endif + /* The code flow is as follows: Step 1: In recv_recovery_from_checkpoint_start(). Step 2: This recv_writer thread is started. diff --git a/storage/innobase/log/log0write.cc b/storage/innobase/log/log0write.cc index 35aaa1f9f89..f0f4bd86411 100644 --- a/storage/innobase/log/log0write.cc +++ b/storage/innobase/log/log0write.cc @@ -1731,6 +1731,14 @@ void log_writer(log_t *log_ptr) { log_t &log = *log_ptr; lsn_t ready_lsn = 0; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("log_writer"); +#else + pthread_setname_np(pthread_self(), "log_writer"); +#endif +#endif + log_writer_mutex_enter(log); for (uint64_t step = 0;; ++step) { @@ -1975,6 +1983,14 @@ void log_flusher(log_t *log_ptr) { log_t &log = *log_ptr; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("log_flusher"); +#else + pthread_setname_np(pthread_self(), "log_flusher"); +#endif +#endif + log_flusher_mutex_enter(log); for (uint64_t step = 0; log.writer_thread_alive.load(); ++step) { @@ -2106,6 +2122,14 @@ void log_write_notifier(log_t *log_ptr) { log_t &log = *log_ptr; lsn_t lsn = log.write_lsn.load() + 1; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("write_notifier"); +#else + pthread_setname_np(pthread_self(), "write_notifier"); +#endif +#endif + log_write_notifier_mutex_enter(log); for (uint64_t step = 0;; ++step) { @@ -2206,6 +2230,14 @@ void log_flush_notifier(log_t *log_ptr) { log_t &log = *log_ptr; lsn_t lsn = log.flushed_to_disk_lsn.load() + 1; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("flusher_notifier"); +#else + pthread_setname_np(pthread_self(), "flusher_notifier"); +#endif +#endif + log_flush_notifier_mutex_enter(log); for (uint64_t step = 0;; ++step) { @@ -2307,6 +2339,14 @@ void log_closer(log_t *log_ptr) { log_t &log = *log_ptr; lsn_t end_lsn = 0; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("log_closer"); +#else + pthread_setname_np(pthread_self(), "log_closer"); +#endif +#endif + log_closer_mutex_enter(log); for (uint64_t step = 0;; ++step) { diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 48582ae20dd..a41c3c3a8ac 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -989,6 +989,14 @@ static void fts_parallel_merge_thread(fts_psort_t *psort_info) { ulint id = psort_info->psort_id; my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("fts_para_merge"); +#else + pthread_setname_np(pthread_self(), "fts_para_merge"); +#endif +#endif + row_fts_merge_insert(psort_info->psort_common->dup->index, psort_info->psort_common->new_table, psort_info->psort_common->all_info, id); diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 9de89ae570a..7092fda31cd 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1568,6 +1568,14 @@ void srv_monitor_thread() { ulint mutex_skipped; ibool last_srv_print_monitor; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("srv_monitor"); +#else + pthread_setname_np(pthread_self(), "srv_monitor"); +#endif +#endif + ut_ad(!srv_read_only_mode); srv_last_monitor_time = last_monitor_time = ut_time(); @@ -1658,6 +1666,14 @@ void srv_error_monitor_thread() { const void *sema = NULL; const void *old_sema = NULL; +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("error_monitor"); +#else + pthread_setname_np(pthread_self(), "error_monitor"); +#endif +#endif + ut_ad(!srv_read_only_mode); old_lsn = log_get_lsn(*log_sys); @@ -2509,6 +2525,14 @@ void srv_master_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("srv_master"); +#else + pthread_setname_np(pthread_self(), "srv_master"); +#endif +#endif + THD *thd = create_thd(false, true, true, 0); ut_ad(!srv_read_only_mode); @@ -2640,6 +2664,14 @@ void srv_worker_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("srv_worker"); +#else + pthread_setname_np(pthread_self(), "srv_worker"); +#endif +#endif + ut_ad(!srv_read_only_mode); ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND); @@ -2887,6 +2919,14 @@ void srv_purge_coordinator_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("purge_coordi"); +#else + pthread_setname_np(pthread_self(), "purge_coordi"); +#endif +#endif + ut_ad(!srv_read_only_mode); ut_a(srv_n_purge_threads >= 1); ut_a(trx_purge_state() == PURGE_STATE_INIT); diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index ab4bdf664fd..35be8e8aa71 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -262,6 +262,15 @@ static bool srv_file_check_mode(const char *name) /*!< in: filename to check */ /** I/o-handler thread function. @param[in] segment The AIO segment the thread will work on */ static void io_handler_thread(ulint segment) { + +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("io_handler"); +#else + pthread_setname_np(pthread_self(), "io_handler"); +#endif +#endif + while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS || buf_page_cleaner_is_active || !os_aio_all_slots_free()) { fil_aio_wait(segment); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 30f8e65e04d..e60e9f133c4 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -739,6 +739,14 @@ void trx_recovery_rollback_thread() { my_thread_init(); +#if defined(__APPLE__) || defined(HAVE_PTHREAD_SETNAME_NP) +#ifdef __APPLE__ + pthread_setname_np("recv_rollback"); +#else + pthread_setname_np(pthread_self(), "recv_rollback"); +#endif +#endif + ut_ad(!srv_read_only_mode); trx_rollback_or_clean_recovered(TRUE);