From 39d248fa555350756a569d766f11eec4c65c5b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 4 May 2018 22:41:36 +0300 Subject: MDEV-16092 Crash in encryption.create_or_replace If the tablespace is dropped or truncated after the space->is_stopping() check in fil_crypt_get_page_throttle_func(), we would proceed to request the page, and eventually report a fatal error. buf_page_get_gen(): Do not retry reading if mode==BUF_GET_POSSIBLY_FREED. lock_rec_block_validate(): Be prepared for a NULL return value when invoking buf_page_get_gen() with mode=BUF_GET_POSSIBLY_FREED. --- storage/innobase/buf/buf0buf.cc | 7 ++++++- storage/innobase/lock/lock0lock.cc | 8 ++++---- storage/xtradb/buf/buf0buf.cc | 7 ++++++- storage/xtradb/lock/lock0lock.cc | 8 ++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e3c2337659e..3b160209cf0 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3189,6 +3189,11 @@ loop: ibuf_inside(mtr)); retries = 0; + } else if (mode == BUF_GET_POSSIBLY_FREED) { + if (err) { + *err = local_err; + } + return NULL; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 12c0051d09f..441fcace7c3 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6895,10 +6895,10 @@ lock_rec_block_validate( page_no, RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr); - - buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); - - ut_ad(lock_rec_validate_page(block)); + if (block) { + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + ut_ad(lock_rec_validate_page(block)); + } mtr_commit(&mtr); fil_space_release(space); diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 83e38fbcc98..12c5c6efb29 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3088,6 +3088,11 @@ loop: ibuf_inside(mtr), trx); retries = 0; + } else if (mode == BUF_GET_POSSIBLY_FREED) { + if (err) { + *err = local_err; + } + return NULL; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index b8446013bc7..549cc411f69 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -6955,10 +6955,10 @@ lock_rec_block_validate( page_no, RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr); - - buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); - - ut_ad(lock_rec_validate_page(block)); + if (block) { + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + ut_ad(lock_rec_validate_page(block)); + } mtr_commit(&mtr); fil_space_release(space); -- cgit v1.2.1