From 995b74ee0db22aeacbfe8f4d19cef94b2fa4000d Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 4 Mar 2004 15:32:16 +0200 Subject: [PATCH] srv0srv.c: Protect the reading of the latest foreign key error explantion buffer with a mutex; in theory, a race condition could cause SHOW INNODB STATUS print garbage characters after the error info; remove the sprintf of the latest UNIQUE KEY error, since the buffer really was always empty --- innobase/srv/srv0srv.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index cea17e9f223..2bb3e8ea60c 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -1434,6 +1434,13 @@ srv_sprintf_innodb_monitor( buf = buf + strlen(buf); ut_a(buf < buf_end + 1500); + /* Conceptually, srv_innodb_monitor_mutex has a very high latching + order level in sync0sync.h, while dict_foreign_err_mutex has a very + low level 135. Therefore we can reserve the latter mutex here without + a danger of a deadlock of threads. */ + + mutex_enter(&dict_foreign_err_mutex); + if (*dict_foreign_err_buf != '\0') { buf += sprintf(buf, "------------------------\n" @@ -1445,18 +1452,7 @@ srv_sprintf_innodb_monitor( } } - ut_a(buf < buf_end + 1500); - - if (*dict_unique_err_buf != '\0') { - buf += sprintf(buf, -"---------------------------------------------------------------\n" -"LATEST UNIQUE KEY ERROR (is masked in REPLACE or INSERT IGNORE)\n" -"---------------------------------------------------------------\n"); - - if (buf_end - buf > 6000) { - buf+= sprintf(buf, "%.4000s", dict_unique_err_buf); - } - } + mutex_exit(&dict_foreign_err_mutex); ut_a(buf < buf_end + 1500);