summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-09-23 11:21:51 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-09-23 11:21:51 +0300
commit456479690b9ee38b0b8a912bf4b6217952c5903b (patch)
tree0dbe86975309e0da797e48cc371626ccc1a154a8
parent1718b9454930c5f02d08f2c62b7c462528c84ed5 (diff)
downloadmariadb-git-bb-10.6-MDEV-26450.tar.gz
MDEV-26445 fixup: Truncate while only holding the tablespace latchbb-10.6-MDEV-26450
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index ae3183703c2..c8467995ec2 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -525,9 +525,6 @@ void mtr_t::commit_shrink(fil_space_t &space)
/* Durably write the reduced FSP_SIZE before truncating the data file. */
log_write_and_flush();
- os_file_truncate(space.chain.start->name, space.chain.start->handle,
- os_offset_t{space.size} << srv_page_size_shift, true);
-
if (m_freed_pages)
{
ut_ad(!m_freed_pages->empty());
@@ -563,6 +560,12 @@ void mtr_t::commit_shrink(fil_space_t &space)
space.is_being_truncated= false;
mysql_mutex_unlock(&fil_system.mutex);
+ /* Truncate the file before releasing the space.latch. File extension
+ (and any allocation of pages beyond the current intended end of the file)
+ is covered by exclusive space.latch, which we are still holding here. */
+ os_file_truncate(space.chain.start->name, space.chain.start->handle,
+ os_offset_t{space.size} << srv_page_size_shift, true);
+
m_memo.for_each_block_in_reverse(CIterate<ReleaseLatches>());
srv_stats.log_write_requests.inc();