diff options
author | unknown <cmiller@zippy.cornsilk.net> | 2006-10-03 13:38:25 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.cornsilk.net> | 2006-10-03 13:38:25 -0400 |
commit | e6eef5c1a765d27e1a8d1c7d707fb416dfa0ec2f (patch) | |
tree | d5a05af2d246695f683a48051134ed0526ea254e /sql/sp.cc | |
parent | 9e145670c41ee58bb4e707988a1b4c6f58dda0b6 (diff) | |
download | mariadb-git-e6eef5c1a765d27e1a8d1c7d707fb416dfa0ec2f.tar.gz |
Bug #14262: SP: DROP PROCEDURE|VIEW (maybe more) write to binlog too late \
(race cond)
It was possible for one thread to interrupt a Data Definition Language
statement and thereby get messages to the binlog out of order. Consider:
Connection 1: Drop Foo x
Connection 2: Create or replace Foo x
Connection 2: Log "Create or replace Foo x"
Connection 1: Log "Drop Foo x"
Local end would have Foo x, but the replicated slaves would not.
The fix for this is to wrap all DDL and logging of a kind in the same mutex.
Since we already use mutexes for the various parts of altering the server,
this only entails moving the logging events down close to the action, inside
the mutex protection.
BitKeeper/etc/collapsed:
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
---
BitKeeper file /home/cmiller/work/mysql/bug14262/my50-bug14262/BitKeeper/etc/collapsed
sql/sp.cc:
Move logging inside the routine drop and update functions, so it can be
protected by a LOCK_open mutex. (The "create" function already had such
a LOCK_open protection.)
sql/sql_acl.cc:
Move logging inside the grant functions, so that it can be protected by
LOCK_grant .
sql/sql_db.cc:
Add comments that describe how each logging event is protected.
sql/sql_parse.cc:
Move all logging statements about DDL statements close to the actual event,
so each can be protected by the same mutex.
sql/sql_table.cc:
Widen the scope of the mutex so that logging events are also protected.
sql/sql_trigger.cc:
Widen the scope of the mutex so that logging events are also protected.
sql/sql_view.cc:
Pass the head of the table linked-list so we can create a logging statement.
Move the logging statement inside the worker function, and notably inside
the LOCK_open mutex. Widen the same mutex a little to make room for logging.
sql/sql_view.h:
Pass the head of the table linked-list so we can create a logging statement.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index a7078da2f50..861ba351160 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -660,6 +660,17 @@ db_drop_routine(THD *thd, int type, sp_name *name) if (table->file->delete_row(table->record[0])) ret= SP_DELETE_ROW_FAILED; } + + if (ret == SP_OK) + { + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); + mysql_bin_log.write(&qinfo); + } + } + close_thread_tables(thd); DBUG_RETURN(ret); } @@ -695,6 +706,17 @@ db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) if ((table->file->update_row(table->record[1],table->record[0]))) ret= SP_WRITE_ROW_FAILED; } + + if (ret == SP_OK) + { + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); + mysql_bin_log.write(&qinfo); + } + } + close_thread_tables(thd); DBUG_RETURN(ret); } @@ -773,6 +795,7 @@ print_field_values(THD *thd, TABLE *table, return SP_INTERNAL_ERROR; } } + return SP_OK; } |