diff -ur orig/innobase/include/srv0srv.h new/innobase/include/srv0srv.h --- orig/innobase/include/srv0srv.h 2007-11-08 11:16:57.000000000 -0500 +++ new/innobase/include/srv0srv.h 2007-11-15 11:42:31.000000000 -0500 @@ -78,6 +78,8 @@ extern ulint srv_log_file_size; extern ulint srv_log_buffer_size; extern ulong srv_flush_log_at_trx_commit; +extern ulong srv_show_locks_held; +extern ulong srv_show_verbose_locks; extern byte srv_latin1_ordering[256];/* The sort order table of the latin1 character set */ diff -ur orig/innobase/lock/lock0lock.c new/innobase/lock/lock0lock.c --- orig/innobase/lock/lock0lock.c 2007-11-08 11:16:56.000000000 -0500 +++ new/innobase/lock/lock0lock.c 2007-11-15 11:42:31.000000000 -0500 @@ -4157,6 +4157,7 @@ #endif /* UNIV_SYNC_DEBUG */ } + if ( srv_show_verbose_locks ) { for (i = 0; i < lock_rec_get_n_bits(lock); i++) { if (lock_rec_get_nth_bit(lock, i)) { @@ -4174,6 +4175,7 @@ putc('\n', file); } } + } /* srv_show_verbose_locks */ mtr_commit(&mtr); if (UNIV_LIKELY_NULL(heap)) { @@ -4345,7 +4347,7 @@ } } - if (!srv_print_innodb_lock_monitor) { + if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) { nth_trx++; goto loop; } @@ -4402,9 +4404,9 @@ nth_lock++; - if (nth_lock >= 10) { + if (nth_lock >= srv_show_locks_held) { fputs( - "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n", + "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n", file); nth_trx++; diff -ur orig/innobase/srv/srv0srv.c new/innobase/srv/srv0srv.c --- orig/innobase/srv/srv0srv.c 2007-11-08 11:16:56.000000000 -0500 +++ new/innobase/srv/srv0srv.c 2007-11-15 11:42:31.000000000 -0500 @@ -114,6 +114,8 @@ ulint srv_log_file_size = ULINT_MAX; /* size in database pages */ ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */ ulong srv_flush_log_at_trx_commit = 1; +ulint srv_show_locks_held = 10; +ulint srv_show_verbose_locks = 0; byte srv_latin1_ordering[256] /* The sort order table of the latin1 character set. The following table is diff -ur orig/libmysqld/set_var.cc new/libmysqld/set_var.cc --- orig/libmysqld/set_var.cc 2007-11-08 11:16:55.000000000 -0500 +++ new/libmysqld/set_var.cc 2007-11-15 11:42:31.000000000 -0500 @@ -455,6 +455,12 @@ sys_var_long_ptr sys_innodb_flush_log_at_trx_commit( "innodb_flush_log_at_trx_commit", &srv_flush_log_at_trx_commit); +sys_var_long_ptr sys_innodb_show_locks_held( + "innodb_show_locks_held", + &srv_show_locks_held); +sys_var_long_ptr sys_innodb_show_verbose_locks( + "innodb_show_verbose_locks", + &srv_show_verbose_locks); #endif /* Condition pushdown to storage engine */ @@ -785,6 +791,8 @@ &sys_innodb_thread_concurrency, &sys_innodb_commit_concurrency, &sys_innodb_flush_log_at_trx_commit, + &sys_innodb_show_locks_held, + &sys_innodb_show_verbose_locks, #endif &sys_trust_routine_creators, &sys_trust_function_creators, @@ -897,6 +905,8 @@ {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG }, {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL}, {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS}, + {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS }, + {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS }, {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR}, {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG }, {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG }, diff -ur orig/sql/ha_innodb.h new/sql/ha_innodb.h --- orig/sql/ha_innodb.h 2007-11-08 11:16:54.000000000 -0500 +++ new/sql/ha_innodb.h 2007-11-15 11:42:31.000000000 -0500 @@ -232,6 +232,8 @@ extern ulong srv_thread_concurrency; extern ulong srv_commit_concurrency; extern ulong srv_flush_log_at_trx_commit; +extern ulong srv_show_locks_held; +extern ulong srv_show_verbose_locks; } bool innobase_init(void); diff -ur orig/sql/mysqld.cc new/sql/mysqld.cc --- orig/sql/mysqld.cc 2007-11-08 11:16:54.000000000 -0500 +++ new/sql/mysqld.cc 2007-11-15 11:50:54.000000000 -0500 @@ -4717,6 +4717,8 @@ OPT_INNODB_MAX_PURGE_LAG, OPT_INNODB_FILE_IO_THREADS, OPT_INNODB_LOCK_WAIT_TIMEOUT, + OPT_INNODB_SHOW_LOCKS_HELD, + OPT_INNODB_SHOW_VERBOSE_LOCKS, OPT_INNODB_THREAD_CONCURRENCY, OPT_INNODB_COMMIT_CONCURRENCY, OPT_INNODB_FORCE_RECOVERY, @@ -5027,6 +5029,14 @@ (gptr*) &srv_flush_log_at_trx_commit, (gptr*) &srv_flush_log_at_trx_commit, 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, + {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD, + "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.", + (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held, + 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0}, + {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS, + "Whether to show records locked in SHOW INNODB STATUS.", + (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks, + 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0}, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method, (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, diff -ur orig/sql/set_var.cc new/sql/set_var.cc --- orig/sql/set_var.cc 2007-11-08 11:16:54.000000000 -0500 +++ new/sql/set_var.cc 2007-11-15 11:49:27.000000000 -0500 @@ -455,6 +455,12 @@ sys_var_long_ptr sys_innodb_flush_log_at_trx_commit( "innodb_flush_log_at_trx_commit", &srv_flush_log_at_trx_commit); +sys_var_long_ptr sys_innodb_show_locks_held( + "innodb_show_locks_held", + &srv_show_locks_held); +sys_var_long_ptr sys_innodb_show_verbose_locks( + "innodb_show_verbose_locks", + &srv_show_verbose_locks); #endif /* Condition pushdown to storage engine */ @@ -785,6 +791,8 @@ &sys_innodb_thread_concurrency, &sys_innodb_commit_concurrency, &sys_innodb_flush_log_at_trx_commit, + &sys_innodb_show_locks_held, + &sys_innodb_show_verbose_locks, #endif &sys_trust_routine_creators, &sys_trust_function_creators, @@ -897,6 +905,8 @@ {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG }, {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL}, {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS}, + {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS }, + {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS }, {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR}, {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG }, {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },