Skip to content

Commit

Permalink
MDEV-6968: CREATE TABLE crashes with InnoDB plugin
Browse files Browse the repository at this point in the history
Analysis: fil_extend_space_to_desired_size() does not provide file
node to os_aio(). This failed on Windows only because on Windows
we do not use posix_fallocate() to extend file space.

Fix: Add file node to os_aio() function call and make sure that
we do not use NULL pointer at os_aio_array_reserve_slot(). Additionally,
make sure that we do not use 0 as file_block_size (512 is the minimum).
  • Loading branch information
Jan Lindström committed Oct 29, 2014
1 parent b96697d commit 2d2d11f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5255,7 +5255,7 @@ fil_extend_space_to_desired_size(
success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
node->name, node->handle, buf,
offset, page_size * n_pages,
NULL, NULL, 0, FALSE, 0);
node, NULL, 0, FALSE, 0);
#endif /* UNIV_HOTBACKUP */
if (success) {
os_has_said_disk_full = FALSE;
Expand Down
18 changes: 13 additions & 5 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4618,7 +4618,10 @@ os_aio_array_reserve_slot(
slot->write_size = write_size;
slot->page_compression_level = page_compression_level;
slot->page_compression = page_compression;
slot->file_block_size = fil_node_get_block_size(message1);

if (message1) {
slot->file_block_size = fil_node_get_block_size(message1);
}

/* If the space is page compressed and this is write operation
then we compress the page */
Expand Down Expand Up @@ -6556,19 +6559,24 @@ os_file_get_block_size(

if (GetFreeSpace((LPCTSTR)name, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters)) {
fblock_size = BytesPerSector;
fprintf(stderr, "InnoDB: [Note]: Using %ld file block size\n", fblock_size);
} else {
fprintf(stderr, "InnoDB: Warning: GetFreeSpace() failed on file %s\n", name);
os_file_handle_error_no_exit(name, "GetFreeSpace()", FALSE, __FILE__, __LINE__);
}
}
#endif /* __WIN__*/

if (fblock_size > UNIV_PAGE_SIZE/2) {
fprintf(stderr, "InnoDB: Warning: File system for file %s has "
if (fblock_size > UNIV_PAGE_SIZE/2 || fblock_size < 512) {
fprintf(stderr, "InnoDB: Note: File system for file %s has "
"file block size %lu not supported for page_size %lu\n",
name, fblock_size, UNIV_PAGE_SIZE);
fblock_size = UNIV_PAGE_SIZE/2;

if (fblock_size < 512) {
fblock_size = 512;
} else {
fblock_size = UNIV_PAGE_SIZE/2;
}

fprintf(stderr, "InnoDB: Note: Using file block size %ld for file %s\n",
fblock_size, name);
}
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5290,7 +5290,7 @@ fil_extend_space_to_desired_size(
success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
node->name, node->handle, buf,
offset, page_size * n_pages,
NULL, NULL, space_id, NULL, 0, 0, 0);
node, NULL, space_id, NULL, 0, 0, 0);
#endif /* UNIV_HOTBACKUP */
if (success) {
os_has_said_disk_full = FALSE;
Expand Down
18 changes: 13 additions & 5 deletions storage/xtradb/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4737,7 +4737,10 @@ os_aio_array_reserve_slot(
slot->write_size = write_size;
slot->page_compression_level = page_compression_level;
slot->page_compression = page_compression;
slot->file_block_size = fil_node_get_block_size(message1);

if (message1) {
slot->file_block_size = fil_node_get_block_size(message1);
}

/* If the space is page compressed and this is write operation
then we compress the page */
Expand Down Expand Up @@ -6658,19 +6661,24 @@ os_file_get_block_size(

if (GetFreeSpace((LPCTSTR)name, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters)) {
fblock_size = BytesPerSector;
fprintf(stderr, "InnoDB: [Note]: Using %ld file block size\n", fblock_size);
} else {
fprintf(stderr, "InnoDB: Warning: GetFreeSpace() failed on file %s\n", name);
os_file_handle_error_no_exit(name, "GetFreeSpace()", FALSE, __FILE__, __LINE__);
}
}
#endif /* __WIN__*/

if (fblock_size > UNIV_PAGE_SIZE/2) {
fprintf(stderr, "InnoDB: Warning: File system for file %s has "
if (fblock_size > UNIV_PAGE_SIZE/2 || fblock_size < 512) {
fprintf(stderr, "InnoDB: Note: File system for file %s has "
"file block size %lu not supported for page_size %lu\n",
name, fblock_size, UNIV_PAGE_SIZE);
fblock_size = UNIV_PAGE_SIZE/2;

if (fblock_size < 512) {
fblock_size = 512;
} else {
fblock_size = UNIV_PAGE_SIZE/2;
}

fprintf(stderr, "InnoDB: Note: Using file block size %ld for file %s\n",
fblock_size, name);
}
Expand Down

0 comments on commit 2d2d11f

Please sign in to comment.