Skip to content

Commit

Permalink
Merge 10.0 to 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 6, 2018
2 parents 3b7da8a + 55abcfa commit 1d4e1d3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 236 deletions.
111 changes: 0 additions & 111 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,6 @@ fil_mutex_enter_and_prepare_for_io(
{
fil_space_t* space;
ulint count = 0;
ulint count2 = 0;

retry:
mutex_enter(&fil_system->mutex);
Expand All @@ -1108,47 +1107,6 @@ fil_mutex_enter_and_prepare_for_io(
return;
}

if (space->stop_ios) {
ut_ad(space->id != 0);
/* We are going to do a rename file and want to stop new i/o's
for a while */

if (count2 > 20000) {
fputs("InnoDB: Warning: tablespace ", stderr);
ut_print_filename(stderr, space->name);
fprintf(stderr,
" has i/o ops stopped for a long time %lu\n",
(ulong) count2);
}

mutex_exit(&fil_system->mutex);

#ifndef UNIV_HOTBACKUP

/* Wake the i/o-handler threads to make sure pending
i/o's are performed */
os_aio_simulated_wake_handler_threads();

/* The sleep here is just to give IO helper threads a
bit of time to do some work. It is not required that
all IO related to the tablespace being renamed must
be flushed here as we do fil_flush() in
fil_rename_tablespace() as well. */
os_thread_sleep(20000);

#endif /* UNIV_HOTBACKUP */

/* Flush tablespaces so that we can close modified
files in the LRU list */
fil_flush_file_spaces(FIL_TABLESPACE);

os_thread_sleep(20000);

count2++;

goto retry;
}

fil_node_t* node = UT_LIST_GET_LAST(space->chain);

ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain));
Expand Down Expand Up @@ -3204,33 +3162,17 @@ fil_rename_tablespace(
ibool success;
fil_space_t* space;
fil_node_t* node;
ulint count = 0;
char* new_path;
char* old_name;
char* old_path;
const char* not_given = "(name not specified)";

ut_a(id != 0);

retry:
count++;

if (!(count % 1000)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: problems renaming ", stderr);
ut_print_filename(stderr,
old_name_in ? old_name_in : not_given);
fputs(" to ", stderr);
ut_print_filename(stderr, new_name);
fprintf(stderr, ", %lu iterations\n", (ulong) count);
}

mutex_enter(&fil_system->mutex);

space = fil_space_get_by_id(id);

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; );

if (space == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
"Cannot find space id %lu in the tablespace "
Expand All @@ -3242,54 +3184,11 @@ fil_rename_tablespace(
return(FALSE);
}

if (count > 25000) {
space->stop_ios = FALSE;
mutex_exit(&fil_system->mutex);

return(FALSE);
}

/* We temporarily close the .ibd file because we do not trust that
operating systems can rename an open file. For the closing we have to
wait until there are no pending i/o's or flushes on the file. */

space->stop_ios = TRUE;

/* The following code must change when InnoDB supports
multiple datafiles per tablespace. */
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
node = UT_LIST_GET_FIRST(space->chain);

if (node->n_pending > 0
|| node->n_pending_flushes > 0
|| node->being_extended) {
/* There are pending i/o's or flushes or the file is
currently being extended, sleep for a while and
retry */

mutex_exit(&fil_system->mutex);

os_thread_sleep(20000);

goto retry;

} else if (node->modification_counter > node->flush_counter) {
/* Flush the space */

mutex_exit(&fil_system->mutex);

os_thread_sleep(20000);

fil_flush(id);

goto retry;

} else if (node->open) {
/* Close the file */

fil_node_close_file(node, fil_system);
}

/* Check that the old name in the space is right */

if (old_name_in) {
Expand All @@ -3308,17 +3207,9 @@ fil_rename_tablespace(
space, node, new_name, new_path);

if (success) {

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
goto skip_second_rename; );

success = os_file_rename(
innodb_file_data_key, old_path, new_path);

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
skip_second_rename:
success = FALSE; );

if (!success) {
/* We have to revert the changes we made
to the tablespace memory cache */
Expand All @@ -3328,8 +3219,6 @@ fil_rename_tablespace(
}
}

space->stop_ios = FALSE;

mutex_exit(&fil_system->mutex);

#ifndef UNIV_HOTBACKUP
Expand Down
4 changes: 0 additions & 4 deletions storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ struct fil_space_t {
an insert buffer merge request for a
page because it actually was for the
previous incarnation of the space */
ibool stop_ios;/*!< TRUE if we want to rename the
.ibd file of tablespace and want to
stop temporarily posting of new i/o
requests on the file */
bool stop_new_ops;
/*!< we set this TRUE when we start
deleting a single-table tablespace.
Expand Down
7 changes: 4 additions & 3 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,8 @@ os_file_create_simple_func(
/* Use default security attributes and no template file. */

file = CreateFile(
(LPCTSTR) name, access, FILE_SHARE_READ, NULL,
(LPCTSTR) name, access,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
create_flag, attributes, NULL);

if (file == INVALID_HANDLE_VALUE) {
Expand Down Expand Up @@ -1483,7 +1484,7 @@ os_file_create_simple_no_error_handling_func(
DWORD access;
DWORD create_flag;
DWORD attributes = 0;
DWORD share_mode = FILE_SHARE_READ;
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE;
ut_a(name);

ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
Expand Down Expand Up @@ -1764,7 +1765,7 @@ os_file_create_func(

#ifdef __WIN__
DWORD create_flag;
DWORD share_mode = FILE_SHARE_READ;
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE;

on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT
? TRUE : FALSE;
Expand Down
111 changes: 0 additions & 111 deletions storage/xtradb/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ fil_mutex_enter_and_prepare_for_io(
{
fil_space_t* space;
ulint count = 0;
ulint count2 = 0;

retry:
mutex_enter(&fil_system->mutex);
Expand All @@ -1114,47 +1113,6 @@ fil_mutex_enter_and_prepare_for_io(
return;
}

if (space->stop_ios) {
ut_ad(space->id != 0);
/* We are going to do a rename file and want to stop new i/o's
for a while */

if (count2 > 20000) {
fputs("InnoDB: Warning: tablespace ", stderr);
ut_print_filename(stderr, space->name);
fprintf(stderr,
" has i/o ops stopped for a long time %lu\n",
(ulong) count2);
}

mutex_exit(&fil_system->mutex);

#ifndef UNIV_HOTBACKUP

/* Wake the i/o-handler threads to make sure pending
i/o's are performed */
os_aio_simulated_wake_handler_threads();

/* The sleep here is just to give IO helper threads a
bit of time to do some work. It is not required that
all IO related to the tablespace being renamed must
be flushed here as we do fil_flush() in
fil_rename_tablespace() as well. */
os_thread_sleep(20000);

#endif /* UNIV_HOTBACKUP */

/* Flush tablespaces so that we can close modified
files in the LRU list */
fil_flush_file_spaces(FIL_TABLESPACE);

os_thread_sleep(20000);

count2++;

goto retry;
}

fil_node_t* node = UT_LIST_GET_LAST(space->chain);

ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain));
Expand Down Expand Up @@ -3249,33 +3207,17 @@ fil_rename_tablespace(
ibool success;
fil_space_t* space;
fil_node_t* node;
ulint count = 0;
char* new_path;
char* old_name;
char* old_path;
const char* not_given = "(name not specified)";

ut_a(id != 0);

retry:
count++;

if (!(count % 1000)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: problems renaming ", stderr);
ut_print_filename(stderr,
old_name_in ? old_name_in : not_given);
fputs(" to ", stderr);
ut_print_filename(stderr, new_name);
fprintf(stderr, ", %lu iterations\n", (ulong) count);
}

mutex_enter(&fil_system->mutex);

space = fil_space_get_by_id(id);

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; );

if (space == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR,
"Cannot find space id %lu in the tablespace "
Expand All @@ -3287,54 +3229,11 @@ fil_rename_tablespace(
return(FALSE);
}

if (count > 25000) {
space->stop_ios = FALSE;
mutex_exit(&fil_system->mutex);

return(FALSE);
}

/* We temporarily close the .ibd file because we do not trust that
operating systems can rename an open file. For the closing we have to
wait until there are no pending i/o's or flushes on the file. */

space->stop_ios = TRUE;

/* The following code must change when InnoDB supports
multiple datafiles per tablespace. */
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
node = UT_LIST_GET_FIRST(space->chain);

if (node->n_pending > 0
|| node->n_pending_flushes > 0
|| node->being_extended) {
/* There are pending i/o's or flushes or the file is
currently being extended, sleep for a while and
retry */

mutex_exit(&fil_system->mutex);

os_thread_sleep(20000);

goto retry;

} else if (node->modification_counter > node->flush_counter) {
/* Flush the space */

mutex_exit(&fil_system->mutex);

os_thread_sleep(20000);

fil_flush(id);

goto retry;

} else if (node->open) {
/* Close the file */

fil_node_close_file(node, fil_system);
}

/* Check that the old name in the space is right */

if (old_name_in) {
Expand All @@ -3353,17 +3252,9 @@ fil_rename_tablespace(
space, node, new_name, new_path);

if (success) {

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
goto skip_second_rename; );

success = os_file_rename(
innodb_file_data_key, old_path, new_path);

DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
skip_second_rename:
success = FALSE; );

if (!success) {
/* We have to revert the changes we made
to the tablespace memory cache */
Expand All @@ -3373,8 +3264,6 @@ fil_rename_tablespace(
}
}

space->stop_ios = FALSE;

mutex_exit(&fil_system->mutex);

#ifndef UNIV_HOTBACKUP
Expand Down
4 changes: 0 additions & 4 deletions storage/xtradb/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ struct fil_space_t {
an insert buffer merge request for a
page because it actually was for the
previous incarnation of the space */
ibool stop_ios;/*!< TRUE if we want to rename the
.ibd file of tablespace and want to
stop temporarily posting of new i/o
requests on the file */
bool stop_new_ops;
/*!< we set this true when we start
deleting a single-table tablespace.
Expand Down
Loading

0 comments on commit 1d4e1d3

Please sign in to comment.