summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-06-25 15:52:05 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-10-30 12:52:19 +0400
commitafb4878703e71307af0fe8723f8ab10e8d4e0288 (patch)
treed0d506c65d1002648116692e520f2b103772b039
parent20b72a3fad45bd8fc0bf6987fcec0c21b4f36885 (diff)
downloadmariadb-git-afb4878703e71307af0fe8723f8ab10e8d4e0288.tar.gz
MDEV-18783 - Server crash in hp_rb_make_key
In debug build, whenever MEMORY table instance gets closed it performs consistency check without protection. It may cause server crash if executed concurrently with DML. Moved consistency check to ha_heap::external_lock(F_UNLCK), so that it is protected by THR_LOCK.
-rw-r--r--storage/heap/ha_heap.cc4
-rw-r--r--storage/heap/hp_close.c6
2 files changed, 4 insertions, 6 deletions
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index a1b8db34453..60a41cc52e7 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -453,6 +453,10 @@ int ha_heap::reset_auto_increment(ulonglong value)
int ha_heap::external_lock(THD *thd, int lock_type)
{
+#ifndef DBUG_OFF
+ if (lock_type == F_UNLCK && file->s->changed && heap_check_heap(file, 0))
+ return HA_ERR_CRASHED;
+#endif
return 0; // No external locking
}
diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c
index 092048a7c1c..82d6186340a 100644
--- a/storage/heap/hp_close.c
+++ b/storage/heap/hp_close.c
@@ -35,12 +35,6 @@ int hp_close(register HP_INFO *info)
{
int error=0;
DBUG_ENTER("hp_close");
-#ifndef DBUG_OFF
- if (info->s->changed && heap_check_heap(info,0))
- {
- error=my_errno=HA_ERR_CRASHED;
- }
-#endif
info->s->changed=0;
if (info->open_list.data)
heap_open_list=list_delete(heap_open_list,&info->open_list);