Below is the list of changes that have just been committed into a local
5.2 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-10 16:49:11+05:00, svoj@stripped +15 -0
WL#3951 - MyISAM: Additional Error Logs for Data Corruption
When table currption is detected, in addition to current error message
provide following information:
- list of threads (and queries) accessing a table;
- thread_id of a thread that detected corruption;
- source file name and line number where this corruption was detected;
- optional extra information (string).
storage/myisam/CMakeLists.txt@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -1
Added mi_extrafunc.h to myisam sources list.
storage/myisam/Makefile.am@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +1 -1
Added mi_extrafunc.h to myisam headers list.
storage/myisam/ha_myisam.cc@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +40 -0
Added _mi_report_crashed() function (reports additional information
whenever table corruption is detected).
storage/myisam/mi_extrafunc.h@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +21 -0
New BitKeeper file ``storage/myisam/mi_extrafunc.h''
storage/myisam/mi_extrafunc.h@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +0 -0
storage/myisam/mi_locking.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +4 -0
For every call to mi_lock_database(F_[RD|WR|EXTRA_]LCK) - add
current thread to the list of threads accessing this table.
For every call to mi_lock_database(F_UNLCK) - remove current
thread from the list of threads accessing this table.
storage/myisam/mi_test1.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/mi_test2.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/mi_test3.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/myisam_ftdump.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/myisamchk.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/myisamlog.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/myisampack.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +1 -1
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/rt_test.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +2 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisam/sp_test.c@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +1 -0
All standalone programs must define their version of _mi_report_crashed()
by including mi_extrafunc.h.
storage/myisammrg/ha_myisammrg.cc@stripped, 2007-10-10 16:49:08+05:00, svoj@stripped +3 -0
For each unedrlying table initialize `in_use' variable.
diff -Nrup a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt
--- a/storage/myisam/CMakeLists.txt 2007-08-07 02:14:47 +05:00
+++ b/storage/myisam/CMakeLists.txt 2007-10-10 16:49:08 +05:00
@@ -32,7 +32,8 @@ SET(MYISAM_SOURCES ft_boolean_search.c
mi_rfirst.c mi_rlast.c mi_rnext.c mi_rnext_same.c mi_rprev.c mi_rrnd.c
mi_rsame.c mi_rsamepos.c mi_scan.c mi_search.c mi_static.c mi_statrec.c
mi_unique.c mi_update.c mi_write.c rt_index.c rt_key.c rt_mbr.c
- rt_split.c sort.c sp_key.c ft_eval.h myisamdef.h rt_index.h mi_rkey.c)
+ rt_split.c sort.c sp_key.c ft_eval.h mi_extrafunc.h myisamdef.h
+ rt_index.h mi_rkey.c)
IF(NOT SOURCE_SUBLIBS)
diff -Nrup a/storage/myisam/Makefile.am b/storage/myisam/Makefile.am
--- a/storage/myisam/Makefile.am 2006-12-31 04:06:39 +04:00
+++ b/storage/myisam/Makefile.am 2007-10-10 16:49:08 +05:00
@@ -50,7 +50,7 @@ myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS
noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
+ ha_myisam.h mi_extrafunc.h
mi_test1_DEPENDENCIES= $(LIBRARIES)
mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
$(top_builddir)/mysys/libmysys.a \
diff -Nrup a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
--- a/storage/myisam/ha_myisam.cc 2007-09-21 15:42:33 +05:00
+++ b/storage/myisam/ha_myisam.cc 2007-10-10 16:49:08 +05:00
@@ -476,6 +476,45 @@ void mi_check_print_warning(MI_CHECK *pa
va_end(args);
}
+
+/**
+ Report list of threads (and queries) accessing a table, thread_id of a
+ thread that detected corruption, ource file name and line number where
+ this corruption was detected, optional extra information (string).
+
+ This function is intended to be used when table corruption is detected.
+
+ @param[in] file MI_INFO object.
+ @param[in] message Optional error message.
+ @param[in] sfile Name of source file.
+ @param[in] sline Line number in source file.
+
+ @return void
+*/
+
+void _mi_report_crashed(MI_INFO *file, const char *message,
+ const char *sfile, uint sline)
+{
+ THD *cur_thd;
+ LIST *element;
+ char buf[1024];
+ pthread_mutex_lock(&file->s->intern_lock);
+ if ((cur_thd= (THD*) file->in_use.data))
+ sql_print_error("Got an error from thread_id=%lu, %s:%d", cur_thd->thread_id,
+ sfile, sline);
+ else
+ sql_print_error("Got an error from unknown thread, %s:%d", sfile, sline);
+ if (message)
+ sql_print_error("%s", message);
+ for (element= file->s->in_use; element; element= list_rest(element))
+ {
+ THD *thd= (THD*) element->data;
+ sql_print_error("%s", thd ? thd_security_context(thd, buf, sizeof(buf), 0)
+ : "Unknown thread accessing table");
+ }
+ pthread_mutex_unlock(&file->s->intern_lock);
+}
+
}
@@ -1680,6 +1719,7 @@ int ha_myisam::delete_table(const char *
int ha_myisam::external_lock(THD *thd, int lock_type)
{
+ file->in_use.data= thd;
return mi_lock_database(file, !table->s->tmp_table ?
lock_type : ((lock_type == F_UNLCK) ?
F_UNLCK : F_EXTRA_LCK));
diff -Nrup a/storage/myisam/mi_extrafunc.h b/storage/myisam/mi_extrafunc.h
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/myisam/mi_extrafunc.h 2007-10-10 16:49:08 +05:00
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000-2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+void _mi_report_crashed(MI_INFO *file __attribute__((unused)),
+ const char *message __attribute__((unused)),
+ const char *sfile __attribute__((unused)),
+ uint sline __attribute__((unused)))
+{
+}
diff -Nrup a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c
--- a/storage/myisam/mi_locking.c 2007-08-13 18:11:16 +05:00
+++ b/storage/myisam/mi_locking.c 2007-10-10 16:49:08 +05:00
@@ -45,6 +45,7 @@ int mi_lock_database(MI_INFO *info, int
++share->w_locks;
++share->tot_locks;
info->lock_type= lock_type;
+ info->s->in_use= list_add(info->s->in_use, &info->in_use);
DBUG_RETURN(0);
}
@@ -136,6 +137,7 @@ int mi_lock_database(MI_INFO *info, int
}
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
info->lock_type= F_UNLCK;
+ info->s->in_use= list_delete(info->s->in_use, &info->in_use);
break;
case F_RDLCK:
if (info->lock_type == F_WRLCK)
@@ -182,6 +184,7 @@ int mi_lock_database(MI_INFO *info, int
share->r_locks++;
share->tot_locks++;
info->lock_type=lock_type;
+ info->s->in_use= list_add(info->s->in_use, &info->in_use);
break;
case F_WRLCK:
if (info->lock_type == F_RDLCK)
@@ -231,6 +234,7 @@ int mi_lock_database(MI_INFO *info, int
info->invalidator=info->s->invalidator;
share->w_locks++;
share->tot_locks++;
+ info->s->in_use= list_add(info->s->in_use, &info->in_use);
break;
default:
break; /* Impossible */
diff -Nrup a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c
--- a/storage/myisam/mi_test1.c 2007-08-13 18:11:16 +05:00
+++ b/storage/myisam/mi_test1.c 2007-10-10 16:49:08 +05:00
@@ -679,3 +679,5 @@ static void usage()
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c
--- a/storage/myisam/mi_test2.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/mi_test2.c 2007-10-10 16:49:08 +05:00
@@ -1054,3 +1054,5 @@ static void copy_key(MI_INFO *info,uint
}
return;
}
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c
--- a/storage/myisam/mi_test3.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/mi_test3.c 2007-10-10 16:49:08 +05:00
@@ -499,3 +499,5 @@ main()
}
#endif /* __NETWARE__ */
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c
--- a/storage/myisam/myisam_ftdump.c 2007-05-10 14:59:33 +05:00
+++ b/storage/myisam/myisam_ftdump.c 2007-10-10 16:49:08 +05:00
@@ -274,3 +274,5 @@ static void complain(int val) /* Kinda a
exit(1);
}
}
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
--- a/storage/myisam/myisamchk.c 2007-08-02 23:52:32 +05:00
+++ b/storage/myisam/myisamchk.c 2007-10-10 16:49:08 +05:00
@@ -1812,3 +1812,5 @@ void mi_check_print_error(MI_CHECK *para
va_end(args);
DBUG_VOID_RETURN;
}
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c
--- a/storage/myisam/myisamlog.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/myisamlog.c 2007-10-10 16:49:08 +05:00
@@ -845,3 +845,5 @@ static bool cmp_filename(struct file_inf
return 1;
return strcmp(file_info->name,name) ? 1 : 0;
}
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
--- a/storage/myisam/myisampack.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/myisampack.c 2007-10-10 16:49:08 +05:00
@@ -3201,4 +3201,4 @@ static int fakecmp(my_off_t **count1, my
}
#endif
-
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c
--- a/storage/myisam/rt_test.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/rt_test.c 2007-10-10 16:49:08 +05:00
@@ -468,3 +468,5 @@ int main(int argc __attribute__((unused)
exit(0);
}
#endif /*HAVE_RTREE_KEYS*/
+
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c
--- a/storage/myisam/sp_test.c 2007-08-13 18:11:17 +05:00
+++ b/storage/myisam/sp_test.c 2007-10-10 16:49:08 +05:00
@@ -562,3 +562,4 @@ int main(int argc __attribute__((unused)
}
#endif /*HAVE_SPATIAL*/
+#include "mi_extrafunc.h"
diff -Nrup a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
--- a/storage/myisammrg/ha_myisammrg.cc 2007-08-13 18:11:17 +05:00
+++ b/storage/myisammrg/ha_myisammrg.cc 2007-10-10 16:49:08 +05:00
@@ -411,6 +411,9 @@ int ha_myisammrg::extra_opt(enum ha_extr
int ha_myisammrg::external_lock(THD *thd, int lock_type)
{
+ MYRG_TABLE *tmp;
+ for (tmp= file->open_tables; tmp != file->end_table; tmp++)
+ tmp->table->in_use.data= thd;
return myrg_lock_database(file,lock_type);
}