summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <petr/cps@mysql.com/owlet.>2006-08-03 17:23:37 +0400
committerunknown <petr/cps@mysql.com/owlet.>2006-08-03 17:23:37 +0400
commite1ec4de43f3fd812acee1f7c197cd73c929f7675 (patch)
tree65a1eea7379d7090abe7c64d739ce545fdcc4170 /sql/sql_base.cc
parentad73be2eb754a348099d51f4315f9a7b1d638e6f (diff)
downloadmariadb-git-e1ec4de43f3fd812acee1f7c197cd73c929f7675.tar.gz
Fix Bug #20139 Infinite loop after "FLUSH" and "LOCK tabX, general_log"
Due to incorrect handling of FLUSH TABLES, log tables were marked for flush, but not reopened. Later we started to wait for the log table to be closed (disabled) after the flush. And as nobody disabled logs in concurrent treads, the command lasted forever. After internal consultations it was decided to skip logs during FLUSH TABLES. The reasoning is that logging is done in the "log device", whatever it is which is always active and controlled by FLUSH LOGS. So, to flush logs one should use FLUSH LOGS, and not FLUSH TABLES. mysql-test/r/log_tables.result: update result file mysql-test/t/log_tables.test: add a test for the bug sql/sql_base.cc: Skip log tables during FLUSH TABLES
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index db11a3442c2..53ece79562a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1997,17 +1997,17 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length,
&state))
{
- if (table->s->version != refresh_version)
+ /*
+ Here we flush tables marked for flush. However we never flush log
+ tables here. They are flushed only on FLUSH LOGS.
+ */
+ if (table->s->version != refresh_version && !table->s->log_table)
{
DBUG_PRINT("note",
("Found table '%s.%s' with different refresh version",
table_list->db, table_list->table_name));
- /*
- Don't close tables if we are working with a log table or were
- asked not to close the table explicitly
- */
- if (flags & MYSQL_LOCK_IGNORE_FLUSH || table->s->log_table)
+ if (flags & MYSQL_LOCK_IGNORE_FLUSH)
{
/* Force close at once after usage */
thd->version= table->s->version;
@@ -2346,7 +2346,11 @@ void close_old_data_files(THD *thd, TABLE *table, bool abort_locks,
for (; table ; table=table->next)
{
- if (table->s->version != refresh_version)
+ /*
+ Reopen marked for flush. But close log tables. They are flushed only
+ explicitly on FLUSH LOGS
+ */
+ if (table->s->version != refresh_version && !table->s->log_table)
{
found=1;
if (table->db_stat)