InnoDB: Truncate SHOW INNODB STATUS output at the start of the list

of active transactions, if necessary and possible.  (Bug #5436)


innobase/include/lock0lock.h:
  Split lock_print_info() into lock_print_info_summary()
  and lock_print_info_all_transactions().
innobase/lock/lock0lock.c:
  Split lock_print_info() into lock_print_info_summary()
  and lock_print_info_all_transactions().
innobase/include/srv0srv.h:
  srv_printf_innodb_monitor(): Add output parameters trx_start and trx_end.
innobase/srv/srv0srv.c:
  srv_printf_innodb_monitor(): Add output parameters trx_start and trx_end.
sql/ha_innodb.cc:
  innodb_show_status(): Truncate oversized output at the beginning
  of the list of active transactions, if possible.
This commit is contained in:
unknown 2005-04-19 14:35:47 +03:00
commit eb72815b6f
5 changed files with 98 additions and 29 deletions

View file

@ -530,8 +530,15 @@ lock_rec_print(
Prints info of locks for all transactions. */
void
lock_print_info(
/*============*/
lock_print_info_summary(
/*====================*/
FILE* file); /* in: file where to print */
/*************************************************************************
Prints info of locks for each transaction. */
void
lock_print_info_all_transactions(
/*=============================*/
FILE* file); /* in: file where to print */
/*************************************************************************
Validates the lock queue on a table. */

View file

@ -398,7 +398,11 @@ Outputs to a file the output of the InnoDB Monitor. */
void
srv_printf_innodb_monitor(
/*======================*/
FILE* file); /* in: output stream */
FILE* file, /* in: output stream */
ulint* trx_start, /* out: file position of the start of
the list of active transactions */
ulint* trx_end); /* out: file position of the end of
the list of active transactions */
/* Types for the threads existing in the system. Threads of types 4 - 9

View file

@ -4126,21 +4126,10 @@ lock_get_n_rec_locks(void)
Prints info of locks for all transactions. */
void
lock_print_info(
/*============*/
lock_print_info_summary(
/*====================*/
FILE* file) /* in: file where to print */
{
lock_t* lock;
trx_t* trx;
ulint space;
ulint page_no;
page_t* page;
ibool load_page_first = TRUE;
ulint nth_trx = 0;
ulint nth_lock = 0;
ulint i;
mtr_t mtr;
/* We must protect the MySQL thd->query field with a MySQL mutex, and
because the MySQL mutex must be reserved before the kernel_mutex of
InnoDB, we call innobase_mysql_prepare_print_arbitrary_thd() here. */
@ -4179,6 +4168,26 @@ lock_print_info(
fprintf(file,
"Total number of lock structs in row lock hash table %lu\n",
(ulong) lock_get_n_rec_locks());
}
/*************************************************************************
Prints info of locks for each transaction. */
void
lock_print_info_all_transactions(
/*=============================*/
FILE* file) /* in: file where to print */
{
lock_t* lock;
ulint space;
ulint page_no;
page_t* page;
ibool load_page_first = TRUE;
ulint nth_trx = 0;
ulint nth_lock = 0;
ulint i;
mtr_t mtr;
trx_t* trx;
fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");

View file

@ -1470,7 +1470,11 @@ Outputs to a file the output of the InnoDB Monitor. */
void
srv_printf_innodb_monitor(
/*======================*/
FILE* file) /* in: output stream */
FILE* file, /* in: output stream */
ulint* trx_start, /* out: file position of the start of
the list of active transactions */
ulint* trx_end) /* out: file position of the end of
the list of active transactions */
{
double time_elapsed;
time_t current_time;
@ -1519,7 +1523,24 @@ srv_printf_innodb_monitor(
mutex_exit(&dict_foreign_err_mutex);
lock_print_info(file);
lock_print_info_summary(file);
if (trx_start) {
long t = ftell(file);
if (t < 0) {
*trx_start = ULINT_UNDEFINED;
} else {
*trx_start = (ulint) t;
}
}
lock_print_info_all_transactions(file);
if (trx_end) {
long t = ftell(file);
if (t < 0) {
*trx_end = ULINT_UNDEFINED;
} else {
*trx_end = (ulint) t;
}
}
fputs("--------\n"
"FILE I/O\n"
"--------\n", file);
@ -1672,13 +1693,13 @@ loop:
last_monitor_time = time(NULL);
if (srv_print_innodb_monitor) {
srv_printf_innodb_monitor(stderr);
srv_printf_innodb_monitor(stderr, NULL, NULL);
}
if (srv_innodb_status) {
mutex_enter(&srv_monitor_file_mutex);
rewind(srv_monitor_file);
srv_printf_innodb_monitor(srv_monitor_file);
srv_printf_innodb_monitor(srv_monitor_file, NULL, NULL);
os_file_set_eof(srv_monitor_file);
mutex_exit(&srv_monitor_file_mutex);
}