[Commits] Rev 3143: Fix long xtradb shutdown on Windows XP in file:///H:/bzr/5.3/

Vladislav Vaintroub wlad at montyprogram.com
Mon Aug 8 19:40:32 EEST 2011


At file:///H:/bzr/5.3/

------------------------------------------------------------
revno: 3143
revision-id: wlad at montyprogram.com-20110808164041-g6x3vw9au0atg2n1
parent: wlad at montyprogram.com-20110808160133-n7ylyayc55hc0iti
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: 5.3
timestamp: Mon 2011-08-08 18:40:41 +0200
message:
  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.
-------------- next part --------------
=== modified file 'storage/xtradb/os/os0file.c'
--- a/storage/xtradb/os/os0file.c	2011-06-16 12:33:09 +0000
+++ b/storage/xtradb/os/os0file.c	2011-08-08 16:40:41 +0000
@@ -53,6 +53,10 @@
 # endif /* __WIN__ */
 #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
 Unix; the value of os_innodb_umask is initialized in ha_innodb.cc to
 my_umask */
@@ -3235,9 +3239,7 @@
 {
 	if(completion_port)
 	{
-		ut_a(CloseHandle(completion_port));
-		completion_port = 0;
-
+		PostQueuedCompletionStatus(completion_port, 0, IOCP_SHUTDOWN_KEY, NULL);
 	}
 }
 #endif
@@ -3836,11 +3838,17 @@
 	BOOL		ret;
 	DWORD		len;
 	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);
 
+	/* 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) {
 		os_thread_exit(NULL);
 	}



More information about the commits mailing list