From b17b53fb04eaf785633b4eac55ada5ead54c0e85 Mon Sep 17 00:00:00 2001 From: Narayanan Iyer Date: Fri, 15 Feb 2019 17:04:21 -0500 Subject: [PATCH] [DEBUG_ONLY] Fix assert to take into account an edge case with update process We had the update process fail with a SIG-11 (only in a debug build) due to a bad assert. Below is the C-stack trace for the record. (gdb) where #0 pthread_kill () from /usr/lib64/libpthread.so.0 #1 gtm_dump_core () at sr_unix/gtm_dump_core.c:72 #2 gtm_fork_n_core () at sr_unix/gtm_fork_n_core.c:163 #3 generic_signal_handler () at sr_unix/generic_signal_handler.c:341 #4 #5 mutex_deadlock_check () at sr_port/mutex_deadlock_check.c:110 #6 mutex_long_sleep () at sr_unix/mutex.c:513 #7 gtm_mutex_lock () at sr_unix/mutex.c:858 #8 grab_lock () at sr_unix/grab_lock.c:83 #9 updproc_actions () at sr_port/updproc.c:907 #10 updproc () at sr_port/updproc.c:501 #11 mupip_main () at sr_unix/mupip_main.c:124 #12 dlopen_libyottadb () at sr_unix/dlopen_libyottadb.c:148 #13 main () at sr_unix/mupip.c:19 (gdb) f 5 #5 mutex_deadlock_check () at sr_port/mutex_deadlock_check.c:110 110 assert(REPL_ALLOWED(cs_addrs)); (gdb) p cs_addrs $1 = (sgmnt_addrs *) 0x0 106 if ((NULL != repl_csa) && (repl_csa->critical == criticalPtr)) 107 { /* grab_lock going for crit on the jnlpool region. gv_cur_region points to the current region of 108 * interest, which better have REPL_ENABLED or REPL_WAS_ENABLED. Assert that. 109 */ --> 110 assert(REPL_ALLOWED(cs_addrs)); In case of the update process, it is possible we do not have any current region of interest (like the comment in line 107 above indicates) if we are doing a grab_lock() call to add a history record to the replication instance file. The assert is now modified to allow cs_addrs to be NULL only in case of the update process. --- sr_port/mutex_deadlock_check.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sr_port/mutex_deadlock_check.c b/sr_port/mutex_deadlock_check.c index a9a191a4d..eef6d97f8 100644 --- a/sr_port/mutex_deadlock_check.c +++ b/sr_port/mutex_deadlock_check.c @@ -3,7 +3,7 @@ * Copyright (c) 2001-2018 Fidelity National Information * * Services, Inc. and/or its subsidiaries. All rights reserved. * * * - * Copyright (c) 2018 YottaDB LLC and/or its subsidiaries. * + * Copyright (c) 2018-2019 YottaDB LLC and/or its subsidiaries. * * All rights reserved. * * * * This source code contains the intellectual property * @@ -66,6 +66,7 @@ GBLREF jnlpool_addrs_ptr_t jnlpool; GBLREF gd_region *gv_cur_region; GBLREF sgmnt_addrs *cs_addrs; GBLREF volatile boolean_t in_mutex_deadlock_check; +GBLREF boolean_t is_updproc; void mutex_deadlock_check(mutex_struct_ptr_t criticalPtr, sgmnt_addrs *csa) { @@ -105,9 +106,11 @@ void mutex_deadlock_check(mutex_struct_ptr_t criticalPtr, sgmnt_addrs *csa) { if ((NULL != repl_csa) && (repl_csa->critical == criticalPtr)) { /* grab_lock going for crit on the jnlpool region. gv_cur_region points to the current region of - * interest, which better have REPL_ENABLED or REPL_WAS_ENABLED. Assert that. + * interest, which better have REPL_ENABLED or REPL_WAS_ENABLED. Assert that. The only known + * exception is the update process which could be adding a history record to the replication + * instance file in which case it would have no region of interest (i.e. cs_addrs could be NULL). */ - assert(REPL_ALLOWED(cs_addrs)); + assert((is_updproc && (NULL == cs_addrs)) || REPL_ALLOWED(cs_addrs)); /* Most likely, we will have crit on gv_cur_region but it is rarely possible we do not * (e.g. in the below call sequence * gvcst_init -> jnlpool_init -> repl_inst_ftok_counter_halted -> grab_lock