summaryrefslogtreecommitdiff
path: root/storage/maria
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2014-12-15 11:16:33 +0200
committerMichael Widenius <monty@mariadb.org>2014-12-15 11:16:33 +0200
commit4a32d9c0580d6362cfcd86c6d8f103748946e580 (patch)
treefd568279fe634f76e1a5edb0fe69086a97fbffe5 /storage/maria
parent743e2ae433ca981bab5b2f74438e05d275245c8a (diff)
downloadmariadb-git-4a32d9c0580d6362cfcd86c6d8f103748946e580.tar.gz
MDEV-6871 Multi-value insert on MyISAM table that makes slaves crash (when using --skip-external-locking=0)
Problem was that repair() did lock and unlock tables, which leaved already locked tables in wrong state include/my_check_opt.h: Added option T_NO_LOCKS to disable locking during repair() Fixed duplicated bit T_NO_CREATE_RENAME_LSN mysql-test/suite/rpl/r/myisam_external_lock.result: Test case for MDEV-6871 mysql-test/suite/rpl/t/myisam_external_lock-slave.opt: Test case for MDEV-6871 mysql-test/suite/rpl/t/myisam_external_lock.test: Test case for MDEV-6871 storage/maria/ha_maria.cc: Don't lock tables during enable_indexes() Removed some calls to current_thd storage/myisam/ha_myisam.cc: Don't lock tables during enable_indexes() Removed some calls to current_thd
Diffstat (limited to 'storage/maria')
-rw-r--r--storage/maria/ha_maria.cc28
1 files changed, 21 insertions, 7 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 2cafdecc4b1..38ee0758611 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1554,6 +1554,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
MARIA_SHARE *share= file->s;
ha_rows rows= file->state->records;
TRN *old_trn= file->trn;
+ my_bool locking= 0;
DBUG_ENTER("ha_maria::repair");
/*
@@ -1589,12 +1590,18 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
param->out_flag= 0;
strmov(fixed_name, share->open_file_name.str);
- // Don't lock tables if we have used LOCK TABLE
- if (!thd->locked_tables_mode &&
- maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
+ /*
+ Don't lock tables if we have used LOCK TABLE or if we come from
+ enable_index()
+ */
+ if (!thd->locked_tables_mode && ! (param->testflag & T_NO_LOCKS))
{
- _ma_check_print_error(param, ER(ER_CANT_LOCK), my_errno);
- DBUG_RETURN(HA_ADMIN_FAILED);
+ locking= 1;
+ if (maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
+ {
+ _ma_check_print_error(param, ER(ER_CANT_LOCK), my_errno);
+ DBUG_RETURN(HA_ADMIN_FAILED);
+ }
}
if (!do_optimize ||
@@ -1726,7 +1733,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
mysql_mutex_unlock(&share->intern_lock);
thd_proc_info(thd, old_proc_info);
thd_progress_end(thd); // Mark done
- if (!thd->locked_tables_mode)
+ if (locking)
maria_lock_database(file, F_UNLCK);
/* Reset trn, that may have been set by repair */
@@ -1960,6 +1967,13 @@ int ha_maria::enable_indexes(uint mode)
param.op_name= "recreating_index";
param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS | T_SAFE_REPAIR);
+ /*
+ Don't lock and unlock table if it's locked.
+ Normally table should be locked. This test is mostly for safety.
+ */
+ if (likely(file->lock_type != F_UNLCK))
+ param.testflag|= T_NO_LOCKS;
+
if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR)
{
bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_REPAIR;
@@ -2199,7 +2213,7 @@ bool ha_maria::check_and_repair(THD *thd)
{
/* Remove error about crashed table */
thd->warning_info->clear_warning_info(thd->query_id);
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_CRASHED_ON_USAGE,
"Zerofilling moved table %s", table->s->path.str);
sql_print_information("Zerofilling moved table: '%s'",