diff options
author | unknown <guilhem@mysql.com> | 2003-07-11 14:26:44 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2003-07-11 14:26:44 +0200 |
commit | d974959b4f5a965d217597c4d979fee4a7a70506 (patch) | |
tree | 34a41398a9e8bce12d2127daa5a9368be53ca798 /sql/sql_repl.cc | |
parent | f200fa15db3c39639c6467ab114dbff9dc8ff8be (diff) | |
download | mariadb-git-d974959b4f5a965d217597c4d979fee4a7a70506.tar.gz |
Fix for BUG#791:
a safer way of initing the mutexes in MYSQL_LOG.
is_open() is now always thread-safe.
See each file for details.
sql/handler.cc:
is_open() with locks
sql/item_func.cc:
is_open() with locks
sql/log.cc:
No more 'inited'.
We now always use is_open() in a thread-safe manner.
This simplifies some functions (no more need to test is_open() twice).
sql/log_event.cc:
is_open() with locks
sql/mysqld.cc:
Init mutexes for the global MYSQL_LOG objects.
We care about no_rotate, because we can't do it in open() anymore (because
we don't have 'inited' anymore).
sql/repl_failsafe.cc:
is_open() with locks
sql/slave.cc:
init pthread objects (mutexes, conds) in the constructor of st_relay_log_info.
Some better locking in rotate_relay_log().
sql/sql_base.cc:
is_open() with locks
sql/sql_class.h:
Before, we inited LOCK_log in MYSQL_LOG::open(), so in other places of the code
when we were never 100% sure that it had been inited. For example, if the server
was running without --log-bin, ::open() was not called so the mutex was not
inited. We could detect it with !inited, but not safely as 'inited' was not
protected by any mutex.
So now:
we *always* init the LOCK_log mutex, even if the log is not used. We can't init
the mutex in MYSQL_LOG's constructor, because for global objects like
mysql_bin_log, mysql_log etc, the constructor is called before MY_INIT(), but
safe_mutex depends on MY_INIT(). So we have a new function MYSQL_LOG::init_pthread_objects
which we call in main(), after MY_INIT().
For the relay log, we call this function in the constructor of
st_relay_log_info, which is called before any function tries to
use the relay log (the relay log is always invoked as rli.relay_log).
So now we should be safe in all cases and we don't need 'inited'.
sql/sql_db.cc:
is_open() with locks
sql/sql_delete.cc:
is_open() with locks
sql/sql_insert.cc:
is_open() with locks
sql/sql_load.cc:
is_open() with locks
sql/sql_parse.cc:
is_open() with locks
sql/sql_rename.cc:
is_open() with locks
sql/sql_repl.cc:
is_open() with locks
sql/sql_table.cc:
is_open() with locks
sql/sql_update.cc:
is_open() with locks
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e775a5d712e..a671facdc08 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -269,7 +269,7 @@ int purge_master_logs(THD* thd, const char* to_log) const char* errmsg = 0; int res; - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) goto end; mysql_bin_log.make_log_name(search_file_name, to_log); @@ -335,7 +335,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, } #endif - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { errmsg = "Binary log is not open"; my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; @@ -972,7 +972,7 @@ int change_master(THD* thd, MASTER_INFO* mi) int reset_master(THD* thd) { - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG)); return 1; @@ -1010,7 +1010,7 @@ int show_binlog_events(THD* thd) if (send_fields(thd, field_list, 1)) DBUG_RETURN(-1); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open(1)) { LEX_MASTER_INFO *lex_mi = &thd->lex.mi; ha_rows event_count, limit_start, limit_end; @@ -1110,7 +1110,7 @@ int show_binlog_info(THD* thd) String* packet = &thd->packet; packet->length(0); - if (mysql_bin_log.is_open()) + if (mysql_bin_log.is_open(1)) { LOG_INFO li; mysql_bin_log.get_current_log(&li); @@ -1128,7 +1128,7 @@ int show_binlog_info(THD* thd) /* - Send a lost of all binary logs to client + Send a list of all binary logs to client SYNOPSIS show_binlogs() @@ -1148,7 +1148,7 @@ int show_binlogs(THD* thd) String *packet = &thd->packet; uint length; - if (!mysql_bin_log.is_open()) + if (!mysql_bin_log.is_open(1)) { //TODO: Replace with ER() error message send_error(net, 0, "You are not using binary logging"); |