summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlenz@mysql.com <>2004-05-13 19:17:38 +0200
committerlenz@mysql.com <>2004-05-13 19:17:38 +0200
commit55e777572556eb5cd5ef001d6fc4218080849c13 (patch)
tree13f0b0674a2f48cefa1cb04f0b8997ba71ae8c62
parentb3bbac2548ec5f7e9797aa13bd343da686cb685e (diff)
parentcafad010a608e8abe98187f16fcc274451a71b97 (diff)
downloadmariadb-git-55e777572556eb5cd5ef001d6fc4218080849c13.tar.gz
Merge lgrimmer@build.mysql.com:/home/bk/mysql-4.0
into mysql.com:/space/my/mysql-4.0
-rw-r--r--sql/ha_innodb.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index d5bbeb874ad..e330a0b532f 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -325,10 +325,18 @@ innobase_mysql_print_thd(
{
const THD* thd;
const char* s;
+ char buf[301];
thd = (const THD*) input_thd;
- VOID(pthread_mutex_lock(&LOCK_thread_count));
+/* We cannot use LOCK_thread_count to protect this operation because we own
+the InnoDB kernel_mutex when we enter this function, but in freeing of a
+THD object, MySQL first reserves LOCK_thread_count and AFTER THAT InnoDB
+reserves kernel_mutex when freeing the trx object => a deadlock can occur.
+The solution is for MySQL to use a separate mutex to protect thd->query and
+thd->query_len. Someone should do that! This bug has been here for 3 years!
+
+ VOID(pthread_mutex_lock(&LOCK_thread_count)); */
fprintf(f, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id);
@@ -354,15 +362,29 @@ innobase_mysql_print_thd(
if ((s = thd->query)) {
/* determine the length of the query string */
- uint32 i, len = thd->query_length;
+ uint32 i, len;
+
+ len = thd->query_length;
+
+ if (len > 300) {
+ len = 300; /* A TEMPORARY SOLUTION: print at most
+ 300 chars to reduce the probability of
+ a seg fault in a race */
+ }
+
for (i = 0; i < len && s[i]; i++);
+
+ memcpy(buf, s, i); /* use memcpy to reduce the timeframe
+ for a race, compared to fwrite() */
+ buf[300] = '\0';
+
putc('\n', f);
- fwrite(s, 1, i, f);
+ fwrite(buf, 1, i, f);
}
putc('\n', f);
- VOID(pthread_mutex_unlock(&LOCK_thread_count));
+/* VOID(pthread_mutex_unlock(&LOCK_thread_count)); */
}
/*************************************************************************