Commit 16ed1f9c authored by Darshan M N's avatar Darshan M N Committed by Marko Mäkelä

BUG#25053705 INVALID I/O ON TABLE AFTER TRUNCATE

Issue:
======
The issue is that if a fts index is present in a table the space size is
incorrectly calculated in the case of truncate which results in a invalid
read.

Fix:
====
Have a different space size calculation in truncate if fts indexes are
present.

RB:14755
Reviewed-by: default avatarShaohua Wang <shaohua.wang@oracle.com>
parent c2d9c0ce
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2016 MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -290,6 +290,24 @@ buf_read_ahead_random(
below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we
do not try to read outside the bounds of the tablespace! */
if (fil_space_t* space = fil_space_acquire(page_id.space())) {
#ifdef UNIV_DEBUG
if (srv_file_per_table) {
ulint size = 0;
for (const fil_node_t* node =
UT_LIST_GET_FIRST(space->chain);
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
size += os_file_get_size(node->handle)
/ page_size.logical();
}
ut_ad(size==space->size);
}
#endif /* UNIV_DEBUG */
if (high > space->size) {
high = space->size;
}
......
......@@ -2000,9 +2000,22 @@ row_truncate_table_for_mysql(
}
if (is_file_per_table && fsp_flags != ULINT_UNDEFINED) {
fil_reinit_space_header(
table->space,
table->indexes.count + FIL_IBD_FILE_INITIAL_SIZE + 1);
/* A single-table tablespace has initially
FIL_IBD_FILE_INITIAL_SIZE number of pages allocated and an
extra page is allocated for each of the indexes present. But in
the case of clust index 2 pages are allocated and as one is
covered in the calculation as part of table->indexes.count we
take care of the other page by adding 1. */
ulint space_size = table->indexes.count +
FIL_IBD_FILE_INITIAL_SIZE + 1;
if (has_internal_doc_id) {
/* Since aux tables are created for fts indexes and
they use seperate tablespaces. */
space_size -= ib_vector_size(table->fts->indexes);
}
fil_reinit_space_header(table->space, space_size);
}
DBUG_EXECUTE_IF("ib_trunc_crash_with_intermediate_log_checkpoint",
......
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