Commit a2fee983 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Fix long xtradb shutdown on Windows XP

The reason for the long shutdown is hanging in io threads. It appears
that just closing completion port on XP does not necessarily signal 
thread waiting in GetIOCompletionStatus() (even if this works fine
on later Windows versions)

The fix is to wakeup background threads using PostQueuedCompletionStatus()
with a special 'key' parameter indicating shutdown.
parent b5d67260
...@@ -53,6 +53,10 @@ Created 10/21/1995 Heikki Tuuri ...@@ -53,6 +53,10 @@ Created 10/21/1995 Heikki Tuuri
# endif /* __WIN__ */ # endif /* __WIN__ */
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
#ifdef _WIN32
#define IOCP_SHUTDOWN_KEY (ULONG_PTR)-1
#endif
/* This specifies the file permissions InnoDB uses when it creates files in /* This specifies the file permissions InnoDB uses when it creates files in
Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to
my_umask */ my_umask */
...@@ -3235,9 +3239,7 @@ os_aio_array_wake_win_aio_at_shutdown( ...@@ -3235,9 +3239,7 @@ os_aio_array_wake_win_aio_at_shutdown(
{ {
if(completion_port) if(completion_port)
{ {
ut_a(CloseHandle(completion_port)); PostQueuedCompletionStatus(completion_port, 0, IOCP_SHUTDOWN_KEY, NULL);
completion_port = 0;
} }
} }
#endif #endif
...@@ -3836,11 +3838,17 @@ os_aio_windows_handle( ...@@ -3836,11 +3838,17 @@ os_aio_windows_handle(
BOOL ret; BOOL ret;
DWORD len; DWORD len;
BOOL retry = FALSE; BOOL retry = FALSE;
ULONG_PTR dummy_key; ULONG_PTR key;
ret = GetQueuedCompletionStatus(completion_port, &len, &dummy_key, ret = GetQueuedCompletionStatus(completion_port, &len, &key,
(OVERLAPPED **)&slot, INFINITE); (OVERLAPPED **)&slot, INFINITE);
/* If shutdown key was received, repost the shutdown message and exit */
if (ret && (key == IOCP_SHUTDOWN_KEY)) {
PostQueuedCompletionStatus(completion_port, 0, key, NULL);
os_thread_exit(NULL);
}
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
os_thread_exit(NULL); os_thread_exit(NULL);
} }
......
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