summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authormarko@hundin.mysql.fi <>2005-04-06 15:09:15 +0300
committermarko@hundin.mysql.fi <>2005-04-06 15:09:15 +0300
commitf32fe9c154adbd169407c0bf3c11647dc7f0f7b8 (patch)
tree01e8bb5906da4d81b81fcc444d2f985fb80550a8 /innobase
parent34284d9354ad673138f1050ea78e1da7517b1e8e (diff)
downloadmariadb-git-f32fe9c154adbd169407c0bf3c11647dc7f0f7b8.tar.gz
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)
Diffstat (limited to 'innobase')
-rw-r--r--innobase/include/os0file.h2
-rw-r--r--innobase/os/os0file.c27
-rw-r--r--innobase/srv/srv0start.c5
3 files changed, 30 insertions, 4 deletions
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index d1439faf29f..ebc014df9fd 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -65,6 +65,8 @@ log. */
#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
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 8d1ad895aa9..15f5bf40e51 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -402,8 +402,6 @@ os_file_lock(
"InnoDB: using the same InnoDB data or log files.\n");
}
- close(fd);
-
return(-1);
}
@@ -978,6 +976,7 @@ try_again:
} 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 @@ os_file_create_simple_no_error_handling(
} 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 @@ try_again:
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:
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 @@ try_again:
} 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 {
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 44cf645f170..62df7301cc9 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -789,6 +789,11 @@ open_or_create_data_files(
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,