Browse Source

MDEV-7017: Add function to print semaphore waits

Add function to print to stderr all current semaphore 
waits. This function should be able to executed 
inside a gdb/ddd.
pull/73/head
Jan Lindström 11 years ago
parent
commit
2da6f7ceba
  1. 6
      storage/innobase/include/sync0arr.h
  2. 5
      storage/innobase/include/sync0sync.h
  3. 65
      storage/innobase/sync/sync0arr.c
  4. 10
      storage/innobase/sync/sync0sync.c
  5. 6
      storage/xtradb/include/sync0arr.h
  6. 5
      storage/xtradb/include/sync0sync.h
  7. 64
      storage/xtradb/sync/sync0arr.c
  8. 10
      storage/xtradb/sync/sync0sync.c

6
storage/innobase/include/sync0arr.h

@ -138,6 +138,12 @@ sync_array_print_info(
sync_array_t* arr); /*!< in: wait array */
/**********************************************************************//**
Prints info of the wait array without using any mutexes/semaphores. */
UNIV_INTERN
void
sync_array_print_innodb(void);
#ifndef UNIV_NONINL
#include "sync0arr.ic"
#endif

5
storage/innobase/include/sync0sync.h

@ -777,6 +777,11 @@ extern ut_list_base_node_t mutex_list;
/** Mutex protecting the mutex_list variable */
extern mutex_t mutex_list_mutex;
/*******************************************************************//**
Get sync array */
UNIV_INTERN
sync_array_t*
sync_array_get(void);
#ifndef UNIV_NONINL
#include "sync0sync.ic"

65
storage/innobase/sync/sync0arr.c

@ -2,7 +2,7 @@
Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
Copyright (c) 2013, 2014, MariaDB Corporation. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@ -1111,3 +1111,66 @@ sync_array_print_info(
sync_array_exit(arr);
}
/**********************************************************************//**
Prints info of the wait array without using any mutexes/semaphores. */
UNIV_INTERN
void
sync_array_print_innodb(void)
/*=========================*/
{
ulint i;
sync_array_t* arr = sync_array_get();
fputs("InnoDB: Semaphore wait debug output started for InnoDB:\n", stderr);
for (i = 0; i < arr->n_cells; i++) {
void* wait_object;
sync_cell_t* cell;
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
ulint loop=0;
cell = sync_array_get_nth_cell(arr, i);
wait_object = cell->wait_object;
if (wait_object == NULL || !cell->waiting) {
continue;
}
fputs("InnoDB: Warning: semaphore wait:\n",
stderr);
sync_array_cell_print(stderr, cell, &reserver);
/* Try to output cell information for writer recursive way */
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
sync_cell_t* reserver_wait;
reserver_wait = sync_array_find_thread(arr, reserver);
if (reserver_wait &&
reserver_wait->wait_object != NULL &&
reserver_wait->waiting) {
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
stderr);
sync_array_cell_print(stderr, reserver_wait, &reserver);
if (reserver_wait->thread == reserver) {
reserver = (os_thread_id_t)ULINT_UNDEFINED;
}
} else {
reserver = (os_thread_id_t)ULINT_UNDEFINED;
}
/* This is protection against loop */
if (loop > 100) {
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
break;
}
}
}
fputs("InnoDB: Semaphore wait debug output ended:\n", stderr);
}

10
storage/innobase/sync/sync0sync.c

@ -1665,3 +1665,13 @@ sync_print(
sync_print_wait_info(file);
}
/*******************************************************************//**
Get sync array */
UNIV_INTERN
sync_array_t*
sync_array_get(void)
/*================*/
{
return sync_primary_wait_array;
}

6
storage/xtradb/include/sync0arr.h

@ -138,6 +138,12 @@ sync_array_print_info(
sync_array_t* arr); /*!< in: wait array */
/**********************************************************************//**
Prints info of the wait array without using any mutexes/semaphores. */
UNIV_INTERN
void
sync_array_print_xtradb(void);
#ifndef UNIV_NONINL
#include "sync0arr.ic"
#endif

5
storage/xtradb/include/sync0sync.h

@ -793,6 +793,11 @@ extern ut_list_base_node_t mutex_list;
/** Mutex protecting the mutex_list variable */
extern mutex_t mutex_list_mutex;
/*******************************************************************//**
Get sync array */
UNIV_INTERN
sync_array_t*
sync_array_get(void);
#ifndef UNIV_NONINL
#include "sync0sync.ic"

64
storage/xtradb/sync/sync0arr.c

@ -2,7 +2,7 @@
Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
Copyright (c) 2013, 2014, MariaDB Corporation. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@ -1147,3 +1147,65 @@ sync_array_print_info(
sync_array_exit(arr);
}
/**********************************************************************//**
Prints info of the wait array without using any mutexes/semaphores. */
UNIV_INTERN
void
sync_array_print_xtradb(void)
/*=========================*/
{
ulint i;
sync_array_t* arr = sync_array_get();
fputs("InnoDB: Semaphore wait debug output started for XtraDB:\n", stderr);
for (i = 0; i < arr->n_cells; i++) {
void* wait_object;
sync_cell_t* cell;
os_thread_id_t reserver=(os_thread_id_t)ULINT_UNDEFINED;
ulint loop=0;
cell = sync_array_get_nth_cell(arr, i);
wait_object = cell->wait_object;
if (wait_object == NULL || !cell->waiting) {
continue;
}
fputs("InnoDB: Warning: semaphore wait:\n",
stderr);
sync_array_cell_print(stderr, cell, &reserver);
/* Try to output cell information for writer recursive way */
while (reserver != (os_thread_id_t)ULINT_UNDEFINED) {
sync_cell_t* reserver_wait;
reserver_wait = sync_array_find_thread(arr, reserver);
if (reserver_wait &&
reserver_wait->wait_object != NULL &&
reserver_wait->waiting) {
fputs("InnoDB: Warning: Writer thread is waiting this semaphore:\n",
stderr);
sync_array_cell_print(stderr, reserver_wait, &reserver);
if (reserver_wait->thread == reserver) {
reserver = (os_thread_id_t)ULINT_UNDEFINED;
}
} else {
reserver = (os_thread_id_t)ULINT_UNDEFINED;
}
/* This is protection against loop */
if (loop > 100) {
fputs("InnoDB: Warning: Too many waiting threads.\n", stderr);
break;
}
}
}
fputs("InnoDB: Semaphore wait debug output ended:\n", stderr);
}

10
storage/xtradb/sync/sync0sync.c

@ -1644,3 +1644,13 @@ sync_print(
sync_print_wait_info(file);
}
/*******************************************************************//**
Get sync array */
UNIV_INTERN
sync_array_t*
sync_array_get(void)
/*================*/
{
return sync_primary_wait_array;
}
Loading…
Cancel
Save