From 69a5080f98b98b35301f9fc70170241346484994 Mon Sep 17 00:00:00 2001 From: Manav Kumar Date: Tue, 19 Nov 2024 12:53:54 +0000 Subject: [PATCH] [BACKPORT 2024.2.0][#24979] YSQL: Set pthread_attr_setstacksize to 512 KB in ysql connection manager Summary: Original commit: None / D40088 Set pthread_attr_setstacksize to 512 KB in ysql connection manager. This is to fix crashes involving Alma 9 machines. ``` #0 0x000055e430191fd7 in tcmalloc::tcmalloc_internal::PageTracker::Get(tcmalloc::tcmalloc_internal::Length) () #1 0x000055e430192774 in tcmalloc::tcmalloc_internal::HugePageFiller::TryGet(tcmalloc::tcmalloc_internal::Length, unsigned long) () #2 0x000055e430160b3a in tcmalloc::tcmalloc_internal::HugePageAwareAllocator::New(tcmalloc::tcmalloc_internal::Length, unsigned long) () #3 0x000055e4301437a2 in void* tcmalloc::tcmalloc_internal::SampleifyAllocation >(tcmalloc::tcmalloc_internal::Static&, tcmalloc::tcmalloc_internal::TCMallocPolicy, unsigned long, unsigned long, unsigned long, void*, tcmalloc::tcmalloc_internal::Span*, unsigned long*) () #4 0x000055e43014339b in void* slow_alloc, decltype(nullptr)>(tcmalloc::tcmalloc_internal::TCMallocPolicy, unsigned long, decltype(nullptr)) () #5 0x000055e4301404e6 in malloc () #6 0x00007fc3a67b1d7e in ssl3_setup_write_buffer () from /home/centos/code/local_testing/conn_manager_ssl_auth/yugabyte-b124/bin/../lib/yb-thirdparty/libssl.so.3 #7 0x00007fc3a67ae824 in do_ssl3_write () from /home/centos/code/local_testing/conn_manager_ssl_auth/yugabyte-b124/bin/../lib/yb-thirdparty/libssl.so.3 #8 0x00007fc3a67ae3e1 in ssl3_write_bytes () from /home/centos/code/local_testing/conn_manager_ssl_auth/yugabyte-b124/bin/../lib/yb-thirdparty/libssl.so.3 #9 0x00007fc3a67cc251 in ssl3_do_write () from /home/centos/code/local_testing/conn_manager_ssl_auth/yugabyte-b124/bin/../lib/yb-thirdparty/libssl.so.3 #10 0x00007fc3a67c1a6a in state_machine () from /home/centos/code/local_testing/conn_manager_ssl_auth/yugabyte-b124/bin/../lib/yb-thirdparty/libssl.so.3 #11 0x000055e43013d303 in mm_tls_handshake_cb (handle=) at ../../src/odyssey/third_party/machinarium/sources/tls.c:453 #12 0x000055e43013b9e7 in mm_epoll_step (poll=0x37beffd71a60, timeout=) at ../../src/odyssey/third_party/machinarium/sources/epoll.c:79 #13 0x000055e43013b386 in mm_loop_step (loop=0x37beffd72980) at ../../src/odyssey/third_party/machinarium/sources/loop.c:64 #14 machine_main (arg=0x37beffd72780) at ../../src/odyssey/third_party/machinarium/sources/machine.c:56 #15 0x00007fc3a5e89c02 in start_thread (arg=) at pthread_create.c:443 #16 0x00007fc3a5f0ec40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81``` Note that, this 512 KB value is the same as the value used in tserver and master processes via the min_thread_stack_size_bytes GFlag introduced in https://phorge.dev.yugabyte.com/D38053. Jira: DB-13388 Test Plan: Jenkins: enable connection manager, all tests Reviewers: skumar, stiwary Reviewed By: stiwary Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D40089 --- src/odyssey/third_party/machinarium/sources/machine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/odyssey/third_party/machinarium/sources/machine.c b/src/odyssey/third_party/machinarium/sources/machine.c index 1303e9fd4966..854c2c0524cc 100644 --- a/src/odyssey/third_party/machinarium/sources/machine.c +++ b/src/odyssey/third_party/machinarium/sources/machine.c @@ -8,6 +8,9 @@ #include #include +// Note YB: By default min_thread_stack_size_bytes in YB is set to 512KB. +#define YB_MIN_THREAD_STACK_BYTES 512 * 1024 + __thread mm_machine_t *mm_self = NULL; static int mm_idle_cb(mm_idle_t *handle) @@ -119,7 +122,7 @@ MACHINE_API int64_t machine_create(char *name, machine_coroutine_t function, return -1; } mm_machinemgr_add(&machinarium.machine_mgr, machine); - rc = mm_thread_create(&machine->thread, PTHREAD_STACK_MIN, machine_main, + rc = mm_thread_create(&machine->thread, YB_MIN_THREAD_STACK_BYTES, machine_main, machine); if (rc == -1) { mm_machinemgr_delete(&machinarium.machine_mgr, machine);