diff options
author | unknown <monty@hundin.mysql.fi> | 2001-11-26 02:16:38 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-11-26 02:16:38 +0200 |
commit | 4615e50093d635f07f2940bb9fbe7e1c327b8ebb (patch) | |
tree | 1f8e0f608f035ad5906f6ea2dbbb3006ea2703bd /sql | |
parent | 7ef7d93726929ec678a8b07bed1be7bb56ad4b10 (diff) | |
download | mariadb-git-4615e50093d635f07f2940bb9fbe7e1c327b8ebb.tar.gz |
Fix race condition in ANALYZE TABLE.
Fixed bug where one got an empty set instead of a DEADLOCK error when using BDB tables.
Docs/manual.texi:
Cleanup
configure.in:
Version number change
mysql-test/t/backup.test:
drop used tables
mysql-test/t/bdb-crash.test:
cleanup
mysys/thr_lock.c:
cleanup
sql/mysqld.cc:
safety fix
sql/records.cc:
Fixed bug where one got an empty set instead of a DEADLOCK error when using
BDB tables.
sql/sql_table.cc:
Fix race condition in ANALYZE TABLE.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/records.cc | 44 | ||||
-rw-r--r-- | sql/sql_table.cc | 5 |
3 files changed, 37 insertions, 14 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d5aa54960e8..82fc5556bd8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -718,8 +718,8 @@ void clean_up(bool print_message) if (!opt_noacl) udf_free(); #endif - end_key_cache(); (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ + end_key_cache(); #ifdef USE_RAID end_raid(); #endif diff --git a/sql/records.cc b/sql/records.cc index 0f49b3fa45e..d436f4f58fe 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -132,8 +132,13 @@ static int rr_quick(READ_RECORD *info) { if (tmp == HA_ERR_END_OF_FILE) tmp= -1; - else if (info->print_error) - info->file->print_error(tmp,MYF(0)); + else + { + if (info->print_error) + info->file->print_error(tmp,MYF(0)); + if (tmp < 0) // Fix negative BDB errno + tmp=1; + } } return tmp; } @@ -153,8 +158,13 @@ static int rr_sequential(READ_RECORD *info) { if (tmp == HA_ERR_END_OF_FILE) tmp= -1; - else if (info->print_error) - info->table->file->print_error(tmp,MYF(0)); + else + { + if (info->print_error) + info->table->file->print_error(tmp,MYF(0)); + if (tmp < 0) // Fix negative BDB errno + tmp=1; + } break; } } @@ -168,21 +178,27 @@ static int rr_from_tempfile(READ_RECORD *info) tryNext: if (my_b_read(info->io_cache,info->ref_pos,info->ref_length)) return -1; /* End of file */ - tmp=info->file->rnd_pos(info->record,info->ref_pos); - if (tmp) + if ((tmp=info->file->rnd_pos(info->record,info->ref_pos))) { if (tmp == HA_ERR_END_OF_FILE) tmp= -1; else if (tmp == HA_ERR_RECORD_DELETED) goto tryNext; - else if (info->print_error) - info->file->print_error(tmp,MYF(0)); + else + { + if (info->print_error) + info->file->print_error(tmp,MYF(0)); + if (tmp < 0) // Fix negative BDB errno + tmp=1; + } } return tmp; } /* rr_from_tempfile */ + static int rr_from_pointers(READ_RECORD *info) { + int tmp; byte *cache_pos; tryNext: if (info->cache_pos == info->cache_end) @@ -190,15 +206,19 @@ tryNext: cache_pos=info->cache_pos; info->cache_pos+=info->ref_length; - int tmp=info->file->rnd_pos(info->record,cache_pos); - if (tmp) + if ((tmp=info->file->rnd_pos(info->record,cache_pos))) { if (tmp == HA_ERR_END_OF_FILE) tmp= -1; else if (tmp == HA_ERR_RECORD_DELETED) goto tryNext; - else if (info->print_error) - info->file->print_error(tmp,MYF(0)); + else + { + if (info->print_error) + info->file->print_error(tmp,MYF(0)); + if (tmp < 0) // Fix negative BDB errno + tmp=1; + } } return tmp; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 725aed390be..f4735df5451 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -964,9 +964,11 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, } /* Close all instances of the table to allow repair to rename files */ - if (open_for_modify && table->table->version) + if (lock_type == TL_WRITE && table->table->version) { pthread_mutex_lock(&LOCK_open); + const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open, + "Waiting to get writelock"); mysql_lock_abort(thd,table->table); while (remove_table_from_cache(thd, table->table->table_cache_key, table->table->real_name) && @@ -976,6 +978,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, (void) pthread_cond_wait(&COND_refresh,&LOCK_open); dropping_tables--; } + thd->exit_cond(old_message); pthread_mutex_unlock(&LOCK_open); if (thd->killed) goto err; |