Commit c0c003be authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-20805 follow-up: Catch writes of bogus pages

buf_flush_init_for_writing(): Assert that FIL_PAGE_TYPE is set
except when creating a new data file with a dummy first page.

buf_dblwr_create(): Ensure that FIL_PAGE_TYPE on all pages
will be initialized. Reset buf_dblwr_being_created at the end.
parent cbfd6882
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
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 the Free Software
......@@ -291,6 +291,13 @@ buf_dblwr_create()
ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1);
page_no = buf_block_get_page_no(new_block);
/* We only do this in the debug build, to ensure that
both the check in buf_flush_init_for_writing() and
recv_parse_or_apply_log_rec_body() will see a valid
page type. The flushes of new_block are actually
unnecessary here. */
ut_d(mlog_write_ulint(FIL_PAGE_TYPE + new_block->frame,
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, &mtr));
if (i == FSP_EXTENT_SIZE / 2) {
ut_a(page_no == FSP_EXTENT_SIZE);
......@@ -353,6 +360,7 @@ buf_dblwr_create()
/* Flush the modified pages to disk and make a checkpoint */
log_make_checkpoint_at(LSN_MAX, TRUE);
buf_dblwr_being_created = FALSE;
/* Remove doublewrite pages from LRU */
buf_pool_invalidate();
......
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
Copyright (c) 2013, 2014, Fusion-io
This program is free software; you can redistribute it and/or modify it under
......@@ -745,6 +745,7 @@ buf_flush_init_for_writing(
ib_uint32_t checksum = 0 /* silence bogus gcc warning */;
ut_ad(page);
ut_ad(!newest_lsn || fil_page_get_type(page));
if (page_zip_) {
page_zip_des_t* page_zip;
......
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
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 the Free Software
......@@ -291,6 +291,13 @@ buf_dblwr_create()
ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1);
page_no = buf_block_get_page_no(new_block);
/* We only do this in the debug build, to ensure that
both the check in buf_flush_init_for_writing() and
recv_parse_or_apply_log_rec_body() will see a valid
page type. The flushes of new_block are actually
unnecessary here. */
ut_d(mlog_write_ulint(FIL_PAGE_TYPE + new_block->frame,
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, &mtr));
if (i == FSP_EXTENT_SIZE / 2) {
ut_a(page_no == FSP_EXTENT_SIZE);
......@@ -353,6 +360,7 @@ buf_dblwr_create()
/* Flush the modified pages to disk and make a checkpoint */
log_make_checkpoint_at(LSN_MAX, TRUE);
buf_dblwr_being_created = FALSE;
/* Remove doublewrite pages from LRU */
buf_pool_invalidate();
......
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
Copyright (c) 2013, 2014, Fusion-io
This program is free software; you can redistribute it and/or modify it under
......@@ -787,6 +787,7 @@ buf_flush_init_for_writing(
ib_uint32_t checksum = 0 /* silence bogus gcc warning */;
ut_ad(page);
ut_ad(!newest_lsn || fil_page_get_type(page));
if (page_zip_) {
page_zip_des_t* page_zip;
......
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