MDEV-5878: Failing assertion: mutex_own(mutex) with innodb_use_fallocate=ON.

Analysis: This was merge error on file fil0fil.cc. fil_system mutex was taken twice because of this.

Fix: Remove unnecessary mutex_enter and fixed the issue with slow posix_fallocate usage.
This commit is contained in:
Jan Lindström 2014-03-17 15:49:41 +02:00
commit f1ca1f37c9
6 changed files with 75 additions and 35 deletions

View file

@ -4937,20 +4937,35 @@ retry:
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
os_offset_t start_offset = start_page_no * page_size;
os_offset_t n_pages = (size_after_extend - start_page_no);
os_offset_t len = n_pages * page_size;
if (posix_fallocate(node->handle, start_offset, len) == -1) {
ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file "
"space for file \'%s\' failed. Current size "
INT64PF ", desired size " INT64PF "\n",
node->name, start_offset, len+start_offset);
os_file_handle_error_no_exit(node->name, "posix_fallocate", FALSE);
success = FALSE;
} else {
success = TRUE;
}
mutex_exit(&fil_system->mutex);
success = os_file_set_size(node->name, node->handle,
(size_after_extend
- file_start_page_no) * page_size);
mutex_enter(&fil_system->mutex);
if (success) {
node->size += (size_after_extend - start_page_no);
space->size += (size_after_extend - start_page_no);
node->size += n_pages;
space->size += n_pages;
os_has_said_disk_full = FALSE;
}
node->being_extended = FALSE;
/* If posix_fallocate was used to extent the file space
we need to complete the io. Because no actual writes were
dispatched read operation is enough here. Without this
there will be assertion at shutdown indicating that
all IO is not completed. */
fil_node_complete_io(node, fil_system, OS_FILE_READ);
goto complete_io;
goto file_extended;
}
#endif
@ -5007,24 +5022,13 @@ retry:
space->size += pages_added;
node->size += pages_added;
node->being_extended = FALSE;
#ifdef HAVE_POSIX_FALLOCATE
complete_io:
/* If posix_fallocate was used to extent the file space
we need to complete the io. Because no actual writes were
dispatched read operation is enough here. Without this
there will be assertion at shutdown indicating that
all IO is not completed. */
if (srv_use_posix_fallocate) {
fil_node_complete_io(node, fil_system, OS_FILE_READ);
} else {
fil_node_complete_io(node, fil_system, OS_FILE_WRITE);
}
#else
fil_node_complete_io(node, fil_system, OS_FILE_WRITE);
#endif
/* At this point file has been extended */
file_extended:
node->being_extended = FALSE;
*actual_size = space->size;
#ifndef UNIV_HOTBACKUP