summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-11-22 15:00:26 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-11-22 15:00:26 +0200
commit46f8c46e940c7156f0c7374acda3540237d9e791 (patch)
treecc60dc75095e02d5682262b0024f86d6843212dc
parent377ec1b5c906ea55fa2af9ae048a14eb9e1cf201 (diff)
downloadmariadb-git-46f8c46e940c7156f0c7374acda3540237d9e791.tar.gz
MDEV-30069 InnoDB: Trying to write ... bytes at ... outside the bounds
recv_sys_t::recover_deferred(): If the *.ibd file already exists, adjust the size to the tablespace metadata. It could be that in a multi-batch recovery, we will initially recover an all-zero *.ibd file to a smaller size, and then a fatal error would be reported during the last recovery batch. This bug could be worked around by executing the recovery again. During the initial (failed) recovery attempt, something should have been written to the first page of the file and the file size should be recovered by fil_node_t::read_page0().
-rw-r--r--storage/innobase/log/log0recv.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 81ef4a5b680..06c7b192ec9 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -986,6 +986,20 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p,
DB_SUCCESS == os_file_punch_hole(node->handle, 0, 4096) &&
!my_test_if_thinly_provisioned(node->handle);
#endif
+ /* Mimic fil_node_t::read_page0() in case the file exists and
+ has already been extended to a larger size. */
+ ut_ad(node->size == size);
+ const os_offset_t file_size= os_file_get_size(node->handle);
+ if (file_size != os_offset_t(-1))
+ {
+ const uint32_t n_pages=
+ uint32_t(file_size / fil_space_t::physical_size(flags));
+ if (n_pages > size)
+ {
+ space->size= node->size= n_pages;
+ space->set_committed_size();
+ }
+ }
if (!os_file_set_size(node->name, node->handle,
(size * fil_space_t::physical_size(flags)) &
~4095ULL, is_sparse))