Commit bd5ca6ac authored by Arun Kuruvila's avatar Arun Kuruvila

Bug#25541037: MYSQL BUG ON DELETE

Description:- MyISAM table gets corrupted with concurrent
executions of INSERT, DELETE statements in a particular
sequence.

Analysis:- Due to the inappropriate manipulation of w_lock
and r_lock associated with a MyISAM table, there arises a
scenario where the table's state information becomes
invalid.

Fix:- A lock is introduced to resolve this issue.
parent bbc2e37f
/* /*
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -1172,10 +1172,14 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize) ...@@ -1172,10 +1172,14 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool do_optimize)
if (file->s->base.auto_key) if (file->s->base.auto_key)
update_auto_increment_key(&param, file, 1); update_auto_increment_key(&param, file, 1);
if (optimize_done) if (optimize_done)
{
mysql_mutex_lock(&share->intern_lock);
error = update_state_info(&param, file, error = update_state_info(&param, file,
UPDATE_TIME | UPDATE_OPEN_COUNT | UPDATE_TIME | UPDATE_OPEN_COUNT |
(local_testflag & (local_testflag &
T_STATISTICS ? UPDATE_STAT : 0)); T_STATISTICS ? UPDATE_STAT : 0));
mysql_mutex_unlock(&share->intern_lock);
}
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST); HA_STATUS_CONST);
if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT)) if (rows != file->state->records && ! (param.testflag & T_VERY_SILENT))
......
/* /*
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -4474,6 +4474,10 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update) ...@@ -4474,6 +4474,10 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update)
int error; int error;
uint r_locks=share->r_locks,w_locks=share->w_locks; uint r_locks=share->r_locks,w_locks=share->w_locks;
share->r_locks= share->w_locks= share->tot_locks= 0; share->r_locks= share->w_locks= share->tot_locks= 0;
DBUG_EXECUTE_IF("simulate_incorrect_share_wlock_value",
DEBUG_SYNC_C("after_share_wlock_set_to_0"););
error=_mi_writeinfo(info,WRITEINFO_NO_UNLOCK); error=_mi_writeinfo(info,WRITEINFO_NO_UNLOCK);
share->r_locks=r_locks; share->r_locks=r_locks;
share->w_locks=w_locks; share->w_locks=w_locks;
......
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -229,6 +229,10 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -229,6 +229,10 @@ int mi_lock_database(MI_INFO *info, int lock_type)
info->invalidator=info->s->invalidator; info->invalidator=info->s->invalidator;
share->w_locks++; share->w_locks++;
share->tot_locks++; share->tot_locks++;
DBUG_EXECUTE_IF("simulate_incorrect_share_wlock_value",
DEBUG_SYNC_C("after_share_wlock_increment"););
info->s->in_use= list_add(info->s->in_use, &info->in_use); info->s->in_use= list_add(info->s->in_use, &info->in_use);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment