From 9c9c247da187c13464780fb8f5770f6bfdb5f9cd Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 29 Jun 2017 11:19:09 +0300 Subject: [PATCH] Bug #86865: InnoDB does unnecessary work when extending a tablespace Do not call fil_write_zeros() in fil_space_extend() if posix_fallocate() is available and was successful. --- storage/innobase/fil/fil0fil.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 943eeabc178..f4c6d519225 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -5056,6 +5056,7 @@ fil_space_extend( os_offset_t len; dberr_t err = DB_SUCCESS; + bool need_write_zeros = !node->atomic_write; len = ((node->size + n_node_extend) * page_size) - node_start; ut_ad(len > 0); @@ -5081,11 +5082,16 @@ fil_space_extend( " numbers are described at " REFMAN " operating-system-error-codes.html"; - err = DB_IO_ERROR; + need_write_zeros = true; + } else { + /* Physically writing zeroes is redundant if + posix_fallocate() successfully extended the + tablespace */ + need_write_zeros = false; } #endif /* NO_FALLOCATE || !UNIV_LINUX */ - if (!node->atomic_write || err == DB_IO_ERROR) { + if (need_write_zeros) { bool read_only_mode;