diff options
author | Sulabh Mahajan <sulabh.mahajan@mongodb.com> | 2023-04-17 11:09:04 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-17 01:57:50 +0000 |
commit | 9dae394ef46b0073408580b51f68dc05d8beb21a (patch) | |
tree | bf625ef13e9736f8f2894a639533af2ec844f4cb /src/third_party/wiredtiger | |
parent | e65b0cf4686f853c0d92ea9e255447b70f1e304a (diff) | |
download | mongo-9dae394ef46b0073408580b51f68dc05d8beb21a.tar.gz |
Import wiredtiger: a0b9a458813c18c2aa8152073513f3255e5db6df from branch mongodb-master
ref: ac320a657e..a0b9a45881
for: 7.0.0-rc0
WT-10777 Set name for internal threads for debugging
Diffstat (limited to 'src/third_party/wiredtiger')
-rw-r--r-- | src/third_party/wiredtiger/dist/s_string.ok | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/os_windows.h | 1 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/posix.h | 9 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/lsm/lsm_manager.c | 1 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/os_posix/os_thread.c | 35 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/support/thread_group.c | 1 |
7 files changed, 50 insertions, 1 deletions
diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index 4fe2f45f0bb..ae85c26c330 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -1011,6 +1011,7 @@ notfound notsup novalue nowait +np nrecs nsec nset @@ -1158,6 +1159,7 @@ sdk secretkey sessionp setkv +setname setstr setv setvbuf diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index a47809dc28d..f6b55547ee3 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "ac320a657e7b39abc8fba594a8ede25cd1a41080" + "commit": "a0b9a458813c18c2aa8152073513f3255e5db6df" } diff --git a/src/third_party/wiredtiger/src/include/os_windows.h b/src/third_party/wiredtiger/src/include/os_windows.h index 597c61a0430..aee67750e67 100644 --- a/src/third_party/wiredtiger/src/include/os_windows.h +++ b/src/third_party/wiredtiger/src/include/os_windows.h @@ -13,6 +13,7 @@ typedef CONDITION_VARIABLE wt_cond_t; typedef CRITICAL_SECTION wt_mutex_t; typedef struct { bool created; + uint16_t name_index; /* Not used on Windows */ HANDLE id; } wt_thread_t; diff --git a/src/third_party/wiredtiger/src/include/posix.h b/src/third_party/wiredtiger/src/include/posix.h index faefe528046..8421493c094 100644 --- a/src/third_party/wiredtiger/src/include/posix.h +++ b/src/third_party/wiredtiger/src/include/posix.h @@ -27,6 +27,7 @@ typedef pthread_cond_t wt_cond_t; typedef pthread_mutex_t wt_mutex_t; typedef struct { bool created; + uint16_t name_index; pthread_t id; } wt_thread_t; @@ -38,6 +39,14 @@ typedef struct { #define WT_THREAD_RET void * #define WT_THREAD_RET_VALUE NULL +#ifdef __linux__ +/* + * pthread_setname_np(3) length restriction + */ +#define WT_THREAD_NAME_MAX_LEN 16 + +#endif + /* * WT declaration for calling convention type */ diff --git a/src/third_party/wiredtiger/src/lsm/lsm_manager.c b/src/third_party/wiredtiger/src/lsm/lsm_manager.c index 30c8cd66a3e..6e700fd22b0 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_manager.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_manager.c @@ -211,6 +211,7 @@ __wt_lsm_manager_start(WT_SESSION_IMPL *session) WT_ERR(__wt_open_internal_session(conn, "lsm-worker", false, 0, 0, &worker_session)); worker_session->isolation = WT_ISO_READ_UNCOMMITTED; manager->lsm_worker_cookies[i].session = worker_session; + manager->lsm_worker_cookies[i].tid.name_index = (uint16_t)i; } FLD_SET(conn->server_flags, WT_CONN_SERVER_LSM); diff --git a/src/third_party/wiredtiger/src/os_posix/os_thread.c b/src/third_party/wiredtiger/src/os_posix/os_thread.c index 2036395ee0b..a7a7bcf6ef4 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_thread.c +++ b/src/third_party/wiredtiger/src/os_posix/os_thread.c @@ -8,6 +8,38 @@ #include "wt_internal.h" +#ifdef __linux__ + +/* + * __thread_set_name -- + * Set the pthread-level thread name. If the session name is set, use that, truncated to fit. If + * the caller provides a non-zero thread number, append that to the session name to distinguish + * between multiple threads of the same type/name. + */ +static int +__thread_set_name(WT_SESSION_IMPL *session, uint32_t thread_num, pthread_t thread_id) +{ + char short_name[WT_THREAD_NAME_MAX_LEN] = {0}, thread_name[WT_THREAD_NAME_MAX_LEN] = {0}; + + if (session != NULL && session->name != NULL) { + if (thread_num == 0) + strncpy(thread_name, session->name, WT_THREAD_NAME_MAX_LEN); + else { + strncpy(short_name, session->name, WT_THREAD_NAME_MAX_LEN - 4); + + if (thread_num < 100) + WT_RET(__wt_snprintf( + thread_name, WT_THREAD_NAME_MAX_LEN, "%s %" PRIu32, short_name, thread_num)); + else + WT_RET(__wt_snprintf(thread_name, WT_THREAD_NAME_MAX_LEN, "%s ++", short_name)); + } + thread_name[WT_THREAD_NAME_MAX_LEN - 1] = '\0'; + WT_RET(pthread_setname_np(thread_id, thread_name)); + } + return (0); +} +#endif + /* * __wt_thread_create -- * Create a new thread of control. @@ -28,6 +60,9 @@ __wt_thread_create(WT_SESSION_IMPL *session, wt_thread_t *tidret, WT_SYSCALL_RETRY(pthread_create(&tidret->id, NULL, func, arg), ret); if (ret == 0) { tidret->created = true; +#ifdef __linux__ + WT_IGNORE_RET(__thread_set_name(session, tidret->name_index, tidret->id)); +#endif return (0); } WT_RET_MSG(session, ret, "pthread_create"); diff --git a/src/third_party/wiredtiger/src/support/thread_group.c b/src/third_party/wiredtiger/src/support/thread_group.c index 0f3e3084b54..7a9e00af7d8 100644 --- a/src/third_party/wiredtiger/src/support/thread_group.c +++ b/src/third_party/wiredtiger/src/support/thread_group.c @@ -186,6 +186,7 @@ __thread_group_resize(WT_SESSION_IMPL *session, WT_THREAD_GROUP *group, uint32_t if (LF_ISSET(WT_THREAD_PANIC_FAIL)) F_SET(thread, WT_THREAD_PANIC_FAIL); thread->id = i; + thread->tid.name_index = (uint16_t)i + 1; thread->chk_func = group->chk_func; thread->run_func = group->run_func; thread->stop_func = group->stop_func; |