Skip to content

Commit a8650b6

Browse files
committed
MDEV-25110 [FATAL] InnoDB: Trying to write ... outside the bounds
In commit 118e258 (part of MDEV-23855) we inadvertently broke crash recovery, reintroducing MDEV-11556. fil_system_t::extend_to_recv_size(): Extend all open tablespace files to the recovered size. recv_sys_t::apply(): Invoke fil_system.extend_to_recv_size() at the start of each batch. In this way, any fil_space_t::recv_size changes that were parsed after the file was opened will be applied.
1 parent 549a70d commit a8650b6

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,33 @@ void fil_system_t::close()
13051305
#endif /* UNIV_LINUX */
13061306
}
13071307

1308+
/** Extend all open data files to the recovered size */
1309+
ATTRIBUTE_COLD void fil_system_t::extend_to_recv_size()
1310+
{
1311+
ut_ad(is_initialised());
1312+
mutex_enter(&mutex);
1313+
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space;
1314+
space= UT_LIST_GET_NEXT(space_list, space))
1315+
{
1316+
const uint32_t size= space->recv_size;
1317+
1318+
if (size > space->size)
1319+
{
1320+
if (space->is_closing())
1321+
continue;
1322+
space->reacquire();
1323+
bool success;
1324+
while (fil_space_extend_must_retry(space, UT_LIST_GET_LAST(space->chain),
1325+
size, &success))
1326+
mutex_enter(&mutex);
1327+
/* Crash recovery requires the file extension to succeed. */
1328+
ut_a(success);
1329+
space->release();
1330+
}
1331+
}
1332+
mutex_exit(&mutex);
1333+
}
1334+
13081335
/** Close all tablespace files at shutdown */
13091336
void fil_space_t::close_all()
13101337
{

storage/innobase/include/fil0fil.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2013, 2020, MariaDB Corporation.
4+
Copyright (c) 2013, 2021, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1422,6 +1422,9 @@ struct fil_system_t {
14221422
@retval NULL if this was the last */
14231423
inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck,
14241424
bool encrypt);
1425+
1426+
/** Extend all open data files to the recovered size */
1427+
ATTRIBUTE_COLD void extend_to_recv_size();
14251428
};
14261429

14271430
/** The tablespace memory cache. */

storage/innobase/log/log0recv.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,8 @@ void recv_sys_t::apply(bool last_batch)
26622662
trim(page_id_t(id + srv_undo_space_id_start, t.pages), t.lsn);
26632663
}
26642664

2665+
fil_system.extend_to_recv_size();
2666+
26652667
buf_block_t *free_block= buf_LRU_get_free_block(false);
26662668

26672669
for (map::iterator p= pages.begin(); p != pages.end(); )

0 commit comments

Comments
 (0)