Commit fc655778 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14887 On a 32-bit system, MariaDB 10.2 mishandles data file sizes exceeding 4GiB

This is a regression that was introduced in MySQL 5.7.6 in
https://github.com/mysql/mysql-server/commit/19855664de0245ff24e0753dc82723fc4e2fb7a5

fil_node_open_file(): Use proper 64-bit arithmetics for truncating
size_bytes to a multiple of a file extent size.
parent 09ef28ab
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2017, MariaDB Corporation.
Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -566,7 +566,6 @@ bool
fil_node_open_file(
fil_node_t* node)
{
os_offset_t size_bytes;
bool success;
bool read_only_mode;
fil_space_t* space = node->space;
......@@ -611,7 +610,7 @@ fil_node_open_file(
return(false);
}
size_bytes = os_file_get_size(node->handle);
os_offset_t size_bytes = os_file_get_size(node->handle);
ut_a(size_bytes != (os_offset_t) -1);
ut_a(space->purpose != FIL_TYPE_LOG);
......@@ -694,20 +693,17 @@ fil_node_open_file(
space->free_len = free_len;
if (first_time_open) {
ulint extent_size;
extent_size = psize * FSP_EXTENT_SIZE;
/* After apply-incremental, tablespaces are not extended
to a whole megabyte. Do not cut off valid data. */
/* Truncate the size to a multiple of extent size. */
if (size_bytes >= extent_size) {
size_bytes = ut_2pow_round(size_bytes,
extent_size);
ulint mask = psize * FSP_EXTENT_SIZE - 1;
if (size_bytes <= mask) {
/* .ibd files start smaller than an
extent size. Do not truncate valid data. */
} else {
size_bytes &= ~os_offset_t(mask);
}
node->size = static_cast<ulint>(size_bytes / psize);
node->size = ulint(size_bytes / psize);
space->size += node->size;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment