From 99dc40d6ac2234fa4c990665cc1914c1925cd641 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 30 Sep 2019 20:58:50 +0300 Subject: [PATCH] MDEV-19783 Random crashes and corrupt data in INSTANT-added columns The bug affects MariaDB Server 10.3 or later, but it makes sense to improve CHECK TABLE in earlier versions already. page_validate(): Check REC_INFO_MIN_REC_FLAG in the records. This allows CHECK TABLE to catch more bugs. --- storage/innobase/page/page0page.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index f950af02e31..bda4693648b 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2392,6 +2392,7 @@ page_validate( ulint data_size; const rec_t* rec; const rec_t* old_rec = NULL; + const rec_t* first_rec = NULL; ulint offs; ulint n_slots; ibool ret = FALSE; @@ -2488,6 +2489,21 @@ page_validate( goto func_exit; } + if (rec == first_rec) { + if ((rec_get_info_bits(rec, page_is_comp(page)) + & REC_INFO_MIN_REC_FLAG) + && page_is_leaf(page)) { + ib::error() << "REC_INFO_MIN_REC_FLAG " + "is set in a leaf-page record"; + ret = false; + } + } else if (rec_get_info_bits(rec, page_is_comp(page)) + & REC_INFO_MIN_REC_FLAG) { + ib::error() << "REC_INFO_MIN_REC_FLAG record is not " + "first in page"; + ret = false; + } + /* Check that the records are in the ascending order */ if (count >= PAGE_HEAP_NO_USER_LOW && !page_rec_is_supremum(rec)) { @@ -2599,6 +2615,11 @@ page_validate( old_rec = rec; rec = page_rec_get_next_const(rec); + if (page_rec_is_infimum(old_rec) + && page_rec_is_user_rec(rec)) { + first_rec = rec; + } + /* set old_offsets to offsets; recycle offsets */ { ulint* offs = old_offsets;