Skip to content

Commit

Permalink
[DEBUG_ONLY] Fix assert to take into account an edge case with update…
Browse files Browse the repository at this point in the history
… 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  <signal handler called>
 #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.
  • Loading branch information
nars1 committed Mar 25, 2019
1 parent 4388121 commit b17b53f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sr_port/mutex_deadlock_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b17b53f

Please sign in to comment.