summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorunknown <aivanov@mysql.com>2005-12-13 21:35:24 +0300
committerunknown <aivanov@mysql.com>2005-12-13 21:35:24 +0300
commit778d212b8ceb266c4c8cd2276fcf548c4c0851a3 (patch)
tree7a6cff8fdb54472ba07a9cea2610e458af775dd2 /innobase
parent3bef007191f1e26a68f34c085f6d6611f5a9c388 (diff)
downloadmariadb-git-778d212b8ceb266c4c8cd2276fcf548c4c0851a3.tar.gz
Fix BUG#12071: "Windows hang:'Opening tables' or 'Waiting for
table' lockup". Changes from the innodb-5.0-ss92 snapshot. Do not call os_file_create_tmpfile() at runtime. Instead, create all tempfiles at startup and guard access to them with mutexes. innobase/btr/btr0sea.c: Changes from the innodb-5.0ss92 snapshot. innobase/include/buf0buf.h: Changes from the innodb-5.0ss92 snapshot. innobase/include/os0file.h: Changes from the innodb-5.0ss92 snapshot. innobase/include/srv0srv.h: Changes from the innodb-5.0ss92 snapshot. innobase/row/row0ins.c: Changes from the innodb-5.0ss92 snapshot. innobase/srv/srv0srv.c: Changes from the innodb-5.0ss92 snapshot. innobase/srv/srv0start.c: Changes from the innodb-5.0ss92 snapshot. mysql-test/r/innodb.result: Changes from the innodb-5.0ss92 snapshot. mysql-test/t/innodb.test: Changes from the innodb-5.0ss92 snapshot. sql/ha_innodb.cc: Changes from the innodb-5.0ss92 snapshot.
Diffstat (limited to 'innobase')
-rw-r--r--innobase/btr/btr0sea.c3
-rw-r--r--innobase/include/buf0buf.h14
-rw-r--r--innobase/include/os0file.h2
-rw-r--r--innobase/include/srv0srv.h12
-rw-r--r--innobase/row/row0ins.c27
-rw-r--r--innobase/srv/srv0srv.c12
-rw-r--r--innobase/srv/srv0start.c27
7 files changed, 75 insertions, 22 deletions
diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
index 9b1e93fe700..81f23cfa99c 100644
--- a/innobase/btr/btr0sea.c
+++ b/innobase/btr/btr0sea.c
@@ -889,7 +889,8 @@ Drops a page hash index. */
void
btr_search_drop_page_hash_index(
/*============================*/
- page_t* page) /* in: index page, s- or x-latched */
+ page_t* page) /* in: index page, s- or x-latched, or an index page
+ for which we know that block->buf_fix_count == 0 */
{
hash_table_t* table;
buf_block_t* block;
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 24e7a71c02d..fc1d9a64c7f 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -831,7 +831,13 @@ struct buf_block_struct{
records with the same prefix should be
indexed in the hash index */
- /* The following 6 fields are protected by btr_search_latch: */
+ /* These 6 fields may only be modified when we have
+ an x-latch on btr_search_latch AND
+ a) we are holding an s-latch or x-latch on block->lock or
+ b) we know that block->buf_fix_count == 0.
+
+ An exception to this is when we init or create a page
+ in the buffer pool in buf0buf.c. */
ibool is_hashed; /* TRUE if hash index has already been
built on this page; note that it does
@@ -849,11 +855,7 @@ struct buf_block_struct{
BTR_SEARCH_RIGHT_SIDE in hash
indexing */
dict_index_t* index; /* Index for which the adaptive
- hash index has been created.
- This field may only be modified
- while holding an s-latch or x-latch
- on block->lock and an x-latch on
- btr_search_latch. */
+ hash index has been created. */
/* 6. Debug fields */
#ifdef UNIV_SYNC_DEBUG
rw_lock_t debug_latch; /* in the debug version, each thread
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index 224fd59a76b..02a38dd49ef 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -187,7 +187,7 @@ Creates a temporary file. */
FILE*
os_file_create_tmpfile(void);
/*========================*/
- /* out: temporary file handle (never NULL) */
+ /* out: temporary file handle, or NULL on error */
/***************************************************************************
The os_file_opendir() function opens a directory stream corresponding to the
directory named by the dirname argument. The directory stream is positioned
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index 11347f430d4..99ea4f2de27 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -34,6 +34,18 @@ extern ibool srv_lower_case_table_names;
extern mutex_t srv_monitor_file_mutex;
/* Temporary file for innodb monitor output */
extern FILE* srv_monitor_file;
+/* Mutex for locking srv_dict_tmpfile.
+This mutex has a very high rank; threads reserving it should not
+be holding any InnoDB latches. */
+extern mutex_t srv_dict_tmpfile_mutex;
+/* Temporary file for output from the data dictionary */
+extern FILE* srv_dict_tmpfile;
+/* Mutex for locking srv_misc_tmpfile.
+This mutex has a very low rank; threads reserving it should not
+acquire any further latches or sleep before releasing this one. */
+extern mutex_t srv_misc_tmpfile_mutex;
+/* Temporary file for miscellanous diagnostic output */
+extern FILE* srv_misc_tmpfile;
/* Server parameters which are read from the initfile */
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c
index 5e833372299..32aa0385596 100644
--- a/innobase/row/row0ins.c
+++ b/innobase/row/row0ins.c
@@ -588,20 +588,21 @@ row_ins_set_detailed(
trx_t* trx, /* in: transaction */
dict_foreign_t* foreign) /* in: foreign key constraint */
{
-
- FILE* tf = os_file_create_tmpfile();
-
- if (tf) {
- ut_print_name(tf, trx, foreign->foreign_table_name);
- dict_print_info_on_foreign_key_in_create_format(tf, trx,
- foreign, FALSE);
-
- trx_set_detailed_error_from_file(trx, tf);
-
- fclose(tf);
+ mutex_enter(&srv_misc_tmpfile_mutex);
+ rewind(srv_misc_tmpfile);
+
+ if (os_file_set_eof(srv_misc_tmpfile)) {
+ ut_print_name(srv_misc_tmpfile, trx,
+ foreign->foreign_table_name);
+ dict_print_info_on_foreign_key_in_create_format(
+ srv_misc_tmpfile,
+ trx, foreign, FALSE);
+ trx_set_detailed_error_from_file(trx, srv_misc_tmpfile);
} else {
- trx_set_detailed_error(trx, "temp file creation failed");
+ trx_set_detailed_error(trx, "temp file operation failed");
}
+
+ mutex_exit(&srv_misc_tmpfile_mutex);
}
/*************************************************************************
@@ -709,7 +710,7 @@ row_ins_foreign_report_add_err(
}
if (rec) {
- rec_print(ef, rec, foreign->foreign_index);
+ rec_print(ef, rec, foreign->referenced_index);
}
putc('\n', ef);
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index c585536baee..6e0b9b23266 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -397,6 +397,18 @@ mutex_t srv_innodb_monitor_mutex;
mutex_t srv_monitor_file_mutex;
/* Temporary file for innodb monitor output */
FILE* srv_monitor_file;
+/* Mutex for locking srv_dict_tmpfile.
+This mutex has a very high rank; threads reserving it should not
+be holding any InnoDB latches. */
+mutex_t srv_dict_tmpfile_mutex;
+/* Temporary file for output from the data dictionary */
+FILE* srv_dict_tmpfile;
+/* Mutex for locking srv_misc_tmpfile.
+This mutex has a very low rank; threads reserving it should not
+acquire any further latches or sleep before releasing this one. */
+mutex_t srv_misc_tmpfile_mutex;
+/* Temporary file for miscellanous diagnostic output */
+FILE* srv_misc_tmpfile;
ulint srv_main_thread_process_no = 0;
ulint srv_main_thread_id = 0;
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index e5151ebf631..4f99f340e1c 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -1180,6 +1180,20 @@ NetWare. */
}
}
+ mutex_create(&srv_dict_tmpfile_mutex);
+ mutex_set_level(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
+ srv_dict_tmpfile = os_file_create_tmpfile();
+ if (!srv_dict_tmpfile) {
+ return(DB_ERROR);
+ }
+
+ mutex_create(&srv_misc_tmpfile_mutex);
+ mutex_set_level(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
+ srv_misc_tmpfile = os_file_create_tmpfile();
+ if (!srv_misc_tmpfile) {
+ return(DB_ERROR);
+ }
+
/* Restrict the maximum number of file i/o threads */
if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
@@ -1822,8 +1836,19 @@ innobase_shutdown_for_mysql(void)
mem_free(srv_monitor_file_name);
}
}
-
+ if (srv_dict_tmpfile) {
+ fclose(srv_dict_tmpfile);
+ srv_dict_tmpfile = 0;
+ }
+
+ if (srv_misc_tmpfile) {
+ fclose(srv_misc_tmpfile);
+ srv_misc_tmpfile = 0;
+ }
+
mutex_free(&srv_monitor_file_mutex);
+ mutex_free(&srv_dict_tmpfile_mutex);
+ mutex_free(&srv_misc_tmpfile_mutex);
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
them */