From: Date: April 6 2005 2:09pm Subject: bk commit into 4.1 tree (marko:1.2168) BUG#9381 List-Archive: http://lists.mysql.com/internals/23714 X-Bug: 9381 Message-Id: <200504061209.j36C9OeT013322@hundin.mysql.fi> Below is the list of changes that have just been committed into a local 4.1 repository of marko. When marko does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2168 05/04/06 15:09:15 marko@stripped +3 -0 InnoDB: Avoid test suite failures caused by a locking conflict between two server instances at server shutdown/startup. This conflict on advisory locks appears to be the result of a bug in the operating system; these locks should be released when the files are closed, but somehow that does not always happen immediately in Linux. (Bug #9381) innobase/srv/srv0start.c 1.78 05/04/06 15:09:09 marko@stripped +5 -0 open_or_create_data_files(): Open the first data file with OS_FILE_OPEN_RETRY, to resolve a conflict with a shutting-down instance of the MySQL server. innobase/os/os0file.c 1.100 05/04/06 15:09:09 marko@stripped +23 -4 os_file_lock(): Do not close the file on failure, but let the callers do that. os_file_create(): If create_mode==OS_FILE_OPEN_RETRY and os_file_lock() fails, keep retrying for 100 seconds. innobase/include/os0file.h 1.33 05/04/06 15:09:08 marko@stripped +2 -0 Add OS_FILE_OPEN_RETRY for os_file_create()ing ibdata1 # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: marko # Host: hundin.mysql.fi # Root: /home/marko/mysql-4.1 --- 1.32/innobase/include/os0file.h Thu Oct 21 14:57:38 2004 +++ 1.33/innobase/include/os0file.h Wed Apr 6 15:09:08 2005 @@ -65,6 +65,8 @@ #define OS_FILE_OVERWRITE 53 #define OS_FILE_OPEN_RAW 54 #define OS_FILE_CREATE_PATH 55 +#define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on + the first ibdata file */ #define OS_FILE_READ_ONLY 333 #define OS_FILE_READ_WRITE 444 --- 1.99/innobase/os/os0file.c Mon Mar 7 12:03:26 2005 +++ 1.100/innobase/os/os0file.c Wed Apr 6 15:09:09 2005 @@ -402,8 +402,6 @@ "InnoDB: using the same InnoDB data or log files.\n"); } - close(fd); - return(-1); } @@ -978,6 +976,7 @@ } else if (access_type == OS_FILE_READ_WRITE && os_file_lock(file, name)) { *success = FALSE; + close(file); file = -1; #endif } else { @@ -1090,6 +1089,7 @@ } else if (access_type == OS_FILE_READ_WRITE && os_file_lock(file, name)) { *success = FALSE; + close(file); file = -1; #endif } else { @@ -1141,7 +1141,8 @@ if (create_mode == OS_FILE_OPEN_RAW) { create_flag = OPEN_EXISTING; share_mode = FILE_SHARE_WRITE; - } else if (create_mode == OS_FILE_OPEN) { + } else if (create_mode == OS_FILE_OPEN + || create_mode == OS_FILE_OPEN_RETRY) { create_flag = OPEN_EXISTING; } else if (create_mode == OS_FILE_CREATE) { create_flag = CREATE_NEW; @@ -1232,7 +1233,8 @@ try_again: ut_a(name); - if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW) { + if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW + || create_mode == OS_FILE_OPEN_RETRY) { mode_str = "OPEN"; create_flag = O_RDWR; } else if (create_mode == OS_FILE_CREATE) { @@ -1305,6 +1307,23 @@ } else if (create_mode != OS_FILE_OPEN_RAW && os_file_lock(file, name)) { *success = FALSE; + if (create_mode == OS_FILE_OPEN_RETRY) { + int i; + ut_print_timestamp(stderr); + fputs(" InnoDB: Retrying to lock the first data file\n", + stderr); + for (i = 0; i < 100; i++) { + os_thread_sleep(1000000); + if (!os_file_lock(file, name)) { + *success = TRUE; + return(file); + } + } + ut_print_timestamp(stderr); + fputs(" InnoDB: Unable to open the first data file\n", + stderr); + } + close(file); file = -1; #endif } else { --- 1.77/innobase/srv/srv0start.c Thu Mar 3 17:59:48 2005 +++ 1.78/innobase/srv/srv0start.c Wed Apr 6 15:09:09 2005 @@ -789,6 +789,11 @@ files[i] = os_file_create( name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL, OS_DATA_FILE, &ret); + } else if (i == 0) { + files[i] = os_file_create( + name, OS_FILE_OPEN_RETRY, + OS_FILE_NORMAL, + OS_DATA_FILE, &ret); } else { files[i] = os_file_create( name, OS_FILE_OPEN, OS_FILE_NORMAL,