summaryrefslogtreecommitdiff
path: root/innobase/lock
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-07-25 22:46:28 +0300
committerunknown <monty@mashka.mysql.fi>2002-07-25 22:46:28 +0300
commit6ba1aefe909df2651fcace1fe184e3f093d07ab4 (patch)
treef38c137c73206e3d059517b2bcab6a4a43c957f9 /innobase/lock
parent29cec51551b7a6be66ebf2048f9045eeb0f59d94 (diff)
parent714e9c881e5af8bbb54c336d0327bae8e4559019 (diff)
downloadmariadb-git-6ba1aefe909df2651fcace1fe184e3f093d07ab4.tar.gz
Merge with 3.23.51
Fixed wrong usage of sprintf() in ha_innodb.cc BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-global.h~e80d28157acfdcb5: Auto merged Docs/manual.ja.texi: Auto merged include/config-os2.h: Auto merged innobase/btr/btr0btr.c: Auto merged innobase/btr/btr0cur.c: Auto merged innobase/btr/btr0sea.c: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/data/data0data.c: Auto merged innobase/dict/dict0crea.c: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/fil/fil0fil.c: Auto merged innobase/fsp/fsp0fsp.c: Auto merged innobase/ibuf/ibuf0ibuf.c: Auto merged innobase/include/buf0buf.ic: Auto merged innobase/include/srv0srv.h: Auto merged innobase/lock/lock0lock.c: Auto merged innobase/log/log0log.c: Auto merged innobase/mtr/mtr0mtr.c: Auto merged innobase/os/os0file.c: Auto merged innobase/page/page0cur.c: Auto merged innobase/page/page0page.c: Auto merged innobase/rem/rem0cmp.c: Auto merged innobase/row/row0ins.c: Auto merged innobase/row/row0purge.c: Auto merged innobase/row/row0umod.c: Auto merged innobase/row/row0upd.c: Auto merged innobase/sync/sync0arr.c: Auto merged innobase/sync/sync0sync.c: Auto merged innobase/trx/trx0roll.c: Auto merged innobase/trx/trx0trx.c: Auto merged innobase/trx/trx0undo.c: Auto merged innobase/ut/ut0ut.c: Auto merged isam/pack_isam.c: Auto merged mysys/Makefile.am: Auto merged sql/ha_innodb.h: Auto merged sql/key.cc: Auto merged sql/mini_client.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/table.cc: Auto merged support-files/my-huge.cnf.sh: Auto merged support-files/my-large.cnf.sh: Auto merged support-files/my-medium.cnf.sh: Auto merged support-files/my-small.cnf.sh: Auto merged Docs/manual.texi: Merge with 3.23.51 configure.in: Merge with 3.23.51 include/Makefile.am: Merge with 3.23.51 innobase/dict/dict0load.c: Merge with 3.23.51 innobase/include/univ.i: Merge with 3.23.51 innobase/row/row0mysql.c: Merge with 3.23.51 innobase/srv/srv0srv.c: Merge with 3.23.51 innobase/srv/srv0start.c: Merge with 3.23.51 myisam/mi_cache.c: Merge with 3.23.51 myisammrg/myrg_rnext.c: Merge with 3.23.51 myisammrg/myrg_rprev.c: Merge with 3.23.51 sql/ha_innodb.cc: Merge with 3.23.51 Changed used of sprintf() to make code portable. sql/handler.cc: Indentation change sql/lex.h: Comment cleanup sql/log.cc: Merge with 3.23.51 sql/log_event.h: Merge with 3.23.51 sql/mysql_priv.h: Merge with 3.23.51 sql/mysqld.cc: Merge with 3.23.51 Cleaned up handling of innodb_flush_log_at_trx_commit sql/share/portuguese/errmsg.txt: Merge with 3.23.51 sql/slave.cc: Not merged as this affects many files; Will be fixed in next changeset sql/slave.h: Merge with 3.23.51 sql/sql_acl.cc: Merge with 3.23.51 (no changes) sql/sql_db.cc: Merge with 3.23.51 sql/sql_parse.cc: Merge with 3.23.51 sql/sql_yacc.yy: Merge with 3.23.51 (Renamed NO_FOREIGN_KEY_CHECKS and RELAXED_UNIQUE_CHECKS) support-files/mysql.spec.sh: Merge with 3.23.51
Diffstat (limited to 'innobase/lock')
-rw-r--r--innobase/lock/lock0lock.c148
1 files changed, 100 insertions, 48 deletions
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index b168ba41771..7588a576a86 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -1542,6 +1542,15 @@ lock_rec_enqueue_waiting(
trx = thr_get_trx(thr);
+ if (trx->dict_operation) {
+ ut_print_timestamp(stderr);
+
+ fprintf(stderr,
+" InnoDB: Error: a record lock wait happens in a dictionary operation!\n"
+"InnoDB: Table name %s. Send a bug report to mysql@lists.mysql.com\n",
+index->table_name);
+ }
+
/* Enqueue the lock request that will wait to be granted */
lock = lock_rec_create(type_mode | LOCK_WAIT, rec, index, trx);
@@ -2915,7 +2924,7 @@ lock_table_enqueue_waiting(
trx_t* trx;
ut_ad(mutex_own(&kernel_mutex));
-
+
/* Test if there already is some other reason to suspend thread:
we do not enqueue a lock request if the query thread should be
stopped anyway */
@@ -2927,6 +2936,15 @@ lock_table_enqueue_waiting(
}
trx = thr_get_trx(thr);
+
+ if (trx->dict_operation) {
+ ut_print_timestamp(stderr);
+
+ fprintf(stderr,
+" InnoDB: Error: a table lock wait happens in a dictionary operation!\n"
+"InnoDB: Table name %s. Send a bug report to mysql@lists.mysql.com\n",
+table->name);
+ }
/* Enqueue the lock request that will wait to be granted */
@@ -3309,34 +3327,37 @@ Prints info of a table lock. */
void
lock_table_print(
/*=============*/
+ char* buf, /* in/out: buffer where to print, must be at least
+ 500 bytes */
lock_t* lock) /* in: table type lock */
{
ut_ad(mutex_own(&kernel_mutex));
ut_a(lock_get_type(lock) == LOCK_TABLE);
- printf("TABLE LOCK table %s trx id %lu %lu",
+ buf += sprintf(buf, "TABLE LOCK table %s trx id %lu %lu",
lock->un_member.tab_lock.table->name,
(lock->trx)->id.high, (lock->trx)->id.low);
if (lock_get_mode(lock) == LOCK_S) {
- printf(" lock mode S");
+ buf += sprintf(buf, " lock mode S");
} else if (lock_get_mode(lock) == LOCK_X) {
- printf(" lock_mode X");
+ buf += sprintf(buf, " lock_mode X");
} else if (lock_get_mode(lock) == LOCK_IS) {
- printf(" lock_mode IS");
+ buf += sprintf(buf, " lock_mode IS");
} else if (lock_get_mode(lock) == LOCK_IX) {
- printf(" lock_mode IX");
+ buf += sprintf(buf, " lock_mode IX");
} else if (lock_get_mode(lock) == LOCK_AUTO_INC) {
- printf(" lock_mode AUTO-INC");
+ buf += sprintf(buf, " lock_mode AUTO-INC");
} else {
- printf(" unknown lock_mode %lu", lock_get_mode(lock));
+ buf += sprintf(buf,
+ " unknown lock_mode %lu", lock_get_mode(lock));
}
if (lock_get_wait(lock)) {
- printf(" waiting");
+ buf += sprintf(buf, " waiting");
}
- printf("\n");
+ buf += sprintf(buf, "\n");
}
/*************************************************************************
@@ -3345,6 +3366,8 @@ Prints info of a record lock. */
void
lock_rec_print(
/*===========*/
+ char* buf, /* in/out: buffer where to print, must be at least
+ 500 bytes */
lock_t* lock) /* in: record type lock */
{
page_t* page;
@@ -3352,8 +3375,7 @@ lock_rec_print(
ulint page_no;
ulint i;
ulint count = 0;
- ulint len;
- char buf[200];
+ char* buf_start = buf;
mtr_t mtr;
ut_ad(mutex_own(&kernel_mutex));
@@ -3362,32 +3384,32 @@ lock_rec_print(
space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no;
- printf("RECORD LOCKS space id %lu page no %lu n bits %lu",
+ buf += sprintf(buf, "RECORD LOCKS space id %lu page no %lu n bits %lu",
space, page_no, lock_rec_get_n_bits(lock));
- printf(" table %s index %s trx id %lu %lu",
+ buf += sprintf(buf, " table %s index %s trx id %lu %lu",
lock->index->table->name, lock->index->name,
(lock->trx)->id.high, (lock->trx)->id.low);
if (lock_get_mode(lock) == LOCK_S) {
- printf(" lock mode S");
+ buf += sprintf(buf, " lock mode S");
} else if (lock_get_mode(lock) == LOCK_X) {
- printf(" lock_mode X");
+ buf += sprintf(buf, " lock_mode X");
} else {
ut_error;
}
if (lock_rec_get_gap(lock)) {
- printf(" gap type lock");
+ buf += sprintf(buf, " gap type lock");
}
if (lock_get_wait(lock)) {
- printf(" waiting");
+ buf += sprintf(buf, " waiting");
}
mtr_start(&mtr);
- printf("\n");
+ buf += sprintf(buf, "\n");
/* If the page is not in the buffer pool, we cannot load it
because we have the kernel mutex and ibuf operations would
@@ -3406,28 +3428,28 @@ lock_rec_print(
for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
+ if (buf - buf_start > 300) {
+
+ buf += sprintf(buf,
+ "Suppressing further record lock prints for this page\n");
+ return;
+ }
+
if (lock_rec_get_nth_bit(lock, i)) {
- printf("Record lock, heap no %lu ", i);
+ buf += sprintf(buf, "Record lock, heap no %lu ", i);
if (page) {
- len = rec_sprintf(buf, 190,
+ buf += rec_sprintf(buf, 120,
page_find_rec_with_heap_no(page, i));
- buf[len] = '\0';
- printf("%s", buf);
+ *buf = '\0';
}
- printf("\n");
+ buf += sprintf(buf, "\n");
count++;
}
-
- if (count >= 3) {
- printf(
- "3 LOCKS PRINTED FOR THIS TRX AND PAGE: SUPPRESSING FURTHER PRINTS\n");
- goto end_prints;
- }
}
-end_prints:
+
mtr_commit(&mtr);
}
@@ -3462,8 +3484,10 @@ lock_get_n_rec_locks(void)
Prints info of locks for all transactions. */
void
-lock_print_info(void)
-/*=================*/
+lock_print_info(
+/*============*/
+ char* buf, /* in/out: buffer where to print */
+ char* buf_end)/* in: buffer end */
{
lock_t* lock;
trx_t* trx;
@@ -3476,11 +3500,15 @@ lock_print_info(void)
ulint i;
mtr_t mtr;
- printf("Trx id counter %lu %lu\n",
+ if (buf_end - buf < 600) {
+ return;
+ }
+
+ buf += sprintf(buf, "Trx id counter %lu %lu\n",
ut_dulint_get_high(trx_sys->max_trx_id),
ut_dulint_get_low(trx_sys->max_trx_id));
- printf(
+ buf += sprintf(buf,
"Purge done for trx's n:o < %lu %lu undo n:o < %lu %lu\n",
ut_dulint_get_high(purge_sys->purge_trx_no),
ut_dulint_get_low(purge_sys->purge_trx_no),
@@ -3489,7 +3517,8 @@ lock_print_info(void)
lock_mutex_enter_kernel();
- printf("Total number of lock structs in row lock hash table %lu\n",
+ buf += sprintf(buf,
+ "Total number of lock structs in row lock hash table %lu\n",
lock_get_n_rec_locks());
/* First print info on non-active transactions */
@@ -3497,9 +3526,15 @@ lock_print_info(void)
trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
while (trx) {
+ if (buf_end - buf < 600) {
+ return;
+ }
+
if (trx->conc_state == TRX_NOT_STARTED) {
- printf("---");
- trx_print(trx);
+ buf += sprintf(buf, "---");
+ trx_print(buf, trx);
+
+ buf += strlen(buf);
}
trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
@@ -3528,12 +3563,22 @@ loop:
return;
}
+ if (buf_end - buf < 600) {
+ return;
+ }
+
if (nth_lock == 0) {
- printf("---");
- trx_print(trx);
+ buf += sprintf(buf, "---");
+ trx_print(buf, trx);
+ buf += strlen(buf);
+
+ if (buf_end - buf < 500) {
+ return;
+ }
+
if (trx->read_view) {
- printf(
+ buf += sprintf(buf,
"Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n",
ut_dulint_get_high(trx->read_view->low_limit_id),
ut_dulint_get_low(trx->read_view->low_limit_id),
@@ -3542,16 +3587,17 @@ loop:
}
if (trx->que_state == TRX_QUE_LOCK_WAIT) {
- printf(
+ buf += sprintf(buf,
"------------------TRX IS WAITING FOR THE LOCK:\n");
if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(trx->wait_lock);
+ lock_rec_print(buf, trx->wait_lock);
} else {
- lock_table_print(trx->wait_lock);
+ lock_table_print(buf, trx->wait_lock);
}
- printf(
+ buf += strlen(buf);
+ buf += sprintf(buf,
"------------------\n");
}
}
@@ -3580,6 +3626,10 @@ loop:
goto loop;
}
+ if (buf_end - buf < 500) {
+ return;
+ }
+
if (lock_get_type(lock) == LOCK_REC) {
space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no;
@@ -3600,19 +3650,21 @@ loop:
goto loop;
}
- lock_rec_print(lock);
+ lock_rec_print(buf, lock);
} else {
ut_ad(lock_get_type(lock) == LOCK_TABLE);
- lock_table_print(lock);
+ lock_table_print(buf, lock);
}
+ buf += strlen(buf);
+
load_page_first = TRUE;
nth_lock++;
if (nth_lock >= 10) {
- printf(
+ buf += sprintf(buf,
"10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n");
nth_trx++;