diff options
author | unknown <sasha@mysql.sashanet.com> | 2002-04-01 21:46:23 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2002-04-01 21:46:23 -0700 |
commit | d7cfbff5b0a53ba22bb731dec70c4886d2ff9570 (patch) | |
tree | 0156e4a56e551202f8c7a8237544114db4a8d1bc /sql/log.cc | |
parent | 869e671f98b1a056595e259283bf4e5e40256a20 (diff) | |
download | mariadb-git-d7cfbff5b0a53ba22bb731dec70c4886d2ff9570.tar.gz |
relay_log_space_limit
DBUG_ macro cleanup
buffer boundary cleanup
This changeset, although not fully tested, works for me better than
anything I've had so far, including what is in the repository. I will
push it unless something crashes while I am writing this :-)
mysql-test/r/rpl000014.result:
updated result
mysql-test/r/rpl000015.result:
updated result
mysql-test/r/rpl000016.result:
updated result
mysql-test/r/rpl_log.result:
new result
mysys/mf_iocache.c:
DBUG_ cleanup
mysys/mf_iocache2.c:
DBUG_ fix
sql/log.cc:
added relay_log_space_limit
sql/mysqld.cc:
relay_log_space_limit
sql/slave.cc:
relay_log_space_limit
sql/slave.h:
relay_log_space_limit
sql/sql_class.h:
relay_log_space_limit
sql/sql_repl.cc:
fixed buffer overrun bug
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/sql/log.cc b/sql/log.cc index dc6b1d35cef..c393d2eb413 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -83,7 +83,7 @@ static int find_uniq_filename(char *name) MYSQL_LOG::MYSQL_LOG(): last_time(0), query_start(0),index_file(-1), name(0), log_type(LOG_CLOSED),write_error(0), inited(0), file_id(1),no_rotate(0), - need_start_event(1) + need_start_event(1),bytes_written(0) { /* We don't want to intialize LOCK_Log here as the thread system may @@ -99,6 +99,7 @@ MYSQL_LOG::~MYSQL_LOG() { (void) pthread_mutex_destroy(&LOCK_log); (void) pthread_mutex_destroy(&LOCK_index); + (void) pthread_cond_destroy(&update_cond); } } @@ -233,18 +234,14 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, } else if (log_type == LOG_BIN) { - bool error; - /* - Explanation of the boolean black magic: - if we are supposed to write magic number try write - clean -up if failed - then if index_file has not been previously opened, try to open it - clean up if failed - */ - if ((do_magic && my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4)) || + bool error; + if (do_magic) + { + if (my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4) || open_index(O_APPEND | O_RDWR | O_CREAT)) - goto err; + goto err; + bytes_written += 4; + } if (need_start_event && !no_auto_events) { @@ -462,12 +459,30 @@ err: my_delete(fname, MYF(0)); // do not report error if the file is not there else { + MY_STAT s; my_close(index_file, MYF(MY_WME)); + if (!my_stat(rli->relay_log_name,&s,MYF(0))) + { + sql_print_error("The first log %s failed to stat during purge", + rli->relay_log_name); + error=1; + goto err; + } if (my_rename(fname,index_file_name,MYF(MY_WME)) || (index_file=my_open(index_file_name,O_BINARY|O_RDWR|O_APPEND, MYF(MY_WME)))<0 || my_delete(rli->relay_log_name, MYF(MY_WME))) error=1; + + pthread_mutex_lock(&rli->log_space_lock); + rli->log_space_total -= s.st_size; + fprintf(stderr,"purge_first_log: %ld\n", rli->log_space_total); + pthread_mutex_unlock(&rli->log_space_lock); + // ok to broadcast after the critical region as there is no risk of + // the mutex being destroyed by this thread later - this helps save + // context switches + pthread_cond_broadcast(&rli->log_space_cond); + if ((error=find_first_log(&rli->linfo,"",0/*no mutex*/))) { char buff[22]; @@ -695,6 +710,7 @@ void MYSQL_LOG::new_file(bool inside_mutex) if (thd && thd->slave_thread) r.flags |= LOG_EVENT_FORCED_ROTATE_F; r.write(&log_file); + bytes_written += r.get_event_len(); } // update needs to be signaled even if there is no rotate event // log rotation should give the waiting thread a signal to @@ -728,6 +744,7 @@ bool MYSQL_LOG::append(Log_event* ev) error=1; goto err; } + bytes_written += ev->get_event_len(); if ((uint)my_b_append_tell(&log_file) > max_binlog_size) { new_file(1); @@ -754,6 +771,7 @@ bool MYSQL_LOG::appendv(const char* buf, uint len,...) error = 1; break; } + bytes_written += len; } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint))); if ((uint) my_b_append_tell(&log_file) > max_binlog_size) |