Commit 3c771430 authored by Jan Lindström's avatar Jan Lindström

Write size was not correctly alligned to SECT_SIZE. This lead to situation

where trim corrupted the database. Fixed the issue and added temporal 
guards against unalligned write/trim.
parent 24bc0314
......@@ -188,9 +188,13 @@ fil_compress_page(
#endif /* UNIV_DEBUG */
write_size+=header_len;
#define SECT_SIZE 512
/* Actual write needs to be alligned on block size */
if (write_size % OS_FILE_LOG_BLOCK_SIZE) {
write_size = (write_size + (OS_FILE_LOG_BLOCK_SIZE - (write_size % OS_FILE_LOG_BLOCK_SIZE)));
if (write_size % SECT_SIZE) {
write_size = (write_size + SECT_SIZE-1) & ~(SECT_SIZE-1);
ut_a((write_size % SECT_SIZE) == 0);
}
#ifdef UNIV_DEBUG
......@@ -199,7 +203,6 @@ fil_compress_page(
space_id, fil_space_name(space), len, write_size);
#endif
#define SECT_SIZE 512
srv_stats.page_compression_saved.add((len - write_size));
if ((len - write_size) > 0) {
......
......@@ -6151,9 +6151,10 @@ os_file_trim(
#define SECT_SIZE 512
size_t trim_len = UNIV_PAGE_SIZE - len;
// len here should be alligned to sector size
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
os_offset_t off = slot->offset + len;
// len here should be alligned to sector size
ut_a((trim_len % SECT_SIZE) == 0);
ut_a((len % SECT_SIZE) == 0);
// Nothing to do if trim length is zero or if actual write
// size is initialized and it is smaller than current write size.
......
......@@ -184,9 +184,13 @@ fil_compress_page(
#endif /* UNIV_DEBUG */
write_size+=header_len;
#define SECT_SIZE 512
/* Actual write needs to be alligned on block size */
if (write_size % OS_FILE_LOG_BLOCK_SIZE) {
write_size = (write_size + (OS_FILE_LOG_BLOCK_SIZE - (write_size % OS_FILE_LOG_BLOCK_SIZE)));
if (write_size % SECT_SIZE) {
write_size = (write_size + SECT_SIZE-1) & ~(SECT_SIZE-1);
ut_a((write_size % SECT_SIZE) == 0);
}
#ifdef UNIV_DEBUG
......@@ -195,7 +199,6 @@ fil_compress_page(
space_id, fil_space_name(space), len, write_size);
#endif /* UNIV_DEBUG */
#define SECT_SIZE 512
srv_stats.page_compression_saved.add((len - write_size));
if ((len - write_size) > 0) {
......
......@@ -6206,9 +6206,10 @@ os_file_trim(
#define SECT_SIZE 512
size_t trim_len = UNIV_PAGE_SIZE - len;
// len here should be alligned to sector size
ut_a(trim_len == ((trim_len + SECT_SIZE-1) & ~(SECT_SIZE-1)));
os_offset_t off = slot->offset + len;
// len here should be alligned to sector size
ut_a((trim_len % SECT_SIZE) == 0);
ut_a((len % SECT_SIZE) == 0);
// Nothing to do if trim length is zero or if actual write
// size is initialized and it is smaller than current write 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