Skip to content

Commit

Permalink
MDEV-11369: Implement accurate checks for the metadata record
Browse files Browse the repository at this point in the history
Because changes of the FIL_PAGE_TYPE or PAGE_INSTANT in the root
page are not undo-logged, it is possible that the fields suggest
that instant ADD COLUMN is in effect, even though no metadata
record exists. If the fields are set, proceed to fetch the
metadata record. If the metadata record does not exist, return
success if !index->is_instant().

Also, check that the "infimum" and "supremum" records carry the
strings in the root page. In a later format that supports instant
DROP COLUMN, we will have to store more information in the root
page, so that index->n_core_null_bytes can be determined accurately.
  • Loading branch information
dr-m committed Oct 3, 2018
1 parent c134f56 commit ae4f464
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions storage/innobase/btr/btr0cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,15 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)

ut_ad(index->n_core_null_bytes != dict_index_t::NO_CORE_NULL_BYTES);

if (!index->is_instant()) {
if (fil_page_get_type(root) == FIL_PAGE_INDEX) {
return DB_SUCCESS;
}
if (fil_page_get_type(root) == FIL_PAGE_INDEX) {
ut_ad(!index->is_instant());
return DB_SUCCESS;
}

/* In a later format, these fields in a FIL_PAGE_TYPE_INSTANT
root page could be repurposed for something else. */
if (memcmp(page_get_infimum_rec(root), "infimum", 8)
|| memcmp(page_get_supremum_rec(root), "supremum", 8)) {
incompatible:
ib::error() << "Table " << index->table->name
<< " contains unrecognizable instant ALTER metadata";
Expand All @@ -442,6 +447,17 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)

if (page_rec_is_supremum(rec)
|| !(info_bits & REC_INFO_MIN_REC_FLAG)) {
if (!index->is_instant()) {
/* The FIL_PAGE_TYPE_INSTANT and PAGE_INSTANT may be
assigned even if instant ADD COLUMN was not
committed. Changes to these page header fields are not
undo-logged, but changes to the hidden metadata record
are. If the server is killed and restarted, the page
header fields could remain set even though no metadata
record is present. */
return DB_SUCCESS;
}

ib::error() << "Table " << index->table->name
<< " is missing instant ALTER metadata";
index->table->corrupted = true;
Expand Down

0 comments on commit ae4f464

Please sign in to comment.