Skip to content

Commit

Permalink
Make InnoDB doublewrite buffer creation more robust.
Browse files Browse the repository at this point in the history
buf_dblwr_create(): Remove a bogus check for the buffer pool size.
Theoretically, there is no problem if the doublewrite buffer is
larger than the buffer pool. It could only cause trouble on crash
recovery, and on recovery the doublewrite buffer is read to a buffer
that is allocated outside of the buffer pool. Moreover, this check
was only performed when the database was initialized for the first
time.

On a normal startup, buf_dblwr_init() would not enforce any
rule on the innodb_buffer_pool_size.

Furthermore, in case of an error, commit the mini-transaction in order
to avoid an assertion failure on shutdown. Yes, this will leave the
doublewrite buffer in a corrupted stage, but the doublewrite buffer
should only be initialized when the data files are being initialized
from the scratch in the first place.
  • Loading branch information
dr-m committed Apr 5, 2017
1 parent 35e582c commit 8423294
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions storage/innobase/buf/buf0dblwr.cc
Expand Up @@ -206,19 +206,6 @@ buf_dblwr_create(void)

ib::info() << "Doublewrite buffer not found: creating new";

ulint min_doublewrite_size =
( ( 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
+ FSP_EXTENT_SIZE / 2
+ 100)
* UNIV_PAGE_SIZE);
if (buf_pool_get_curr_size() < min_doublewrite_size) {
ib::error() << "Cannot create doublewrite buffer: you must"
" increase your buffer pool size. Cannot continue"
" operation.";

return(false);
}

block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
TRX_SYS_DOUBLEWRITE
+ TRX_SYS_DOUBLEWRITE_FSEG, &mtr);
Expand All @@ -233,9 +220,9 @@ buf_dblwr_create(void)
" increase your tablespace size."
" Cannot continue operation.";

/* We exit without committing the mtr to prevent
its modifications to the database getting to disk */

/* The mini-transaction did not write anything yet;
we merely failed to allocate a page. */
mtr.commit();
return(false);
}

Expand All @@ -250,7 +237,12 @@ buf_dblwr_create(void)
ib::error() << "Cannot create doublewrite buffer: "
" you must increase your tablespace size."
" Cannot continue operation.";

/* This may essentially corrupt the doublewrite
buffer. However, usually the doublewrite buffer
is created at database initialization, and it
should not matter (just remove all newly created
InnoDB files and restart). */
mtr.commit();
return(false);
}

Expand Down

0 comments on commit 8423294

Please sign in to comment.