Merge svlasenko@bk-internal.mysql.com:/home/bk/mysql-5.0

into  selena.:H:/MYSQL/src/#13377-mysql-5.0


mysql-test/include/check_var_limit.inc:
  Auto merged
mysql-test/include/have_big5.inc:
  Auto merged
mysql-test/include/have_compress.inc:
  Auto merged
mysql-test/include/have_crypt.inc:
  Auto merged
mysql-test/include/have_outfile.inc:
  Auto merged
mysql-test/include/have_query_cache.inc:
  Auto merged
mysql-test/include/have_tis620.inc:
  Auto merged
mysql-test/include/have_ucs2.inc:
  Auto merged
mysql-test/include/have_ujis.inc:
  Auto merged
mysql-test/include/not_embedded.inc:
  Auto merged
mysql-test/include/system_db_struct.inc:
  Auto merged
mysql-test/include/test_outfile.inc:
  Auto merged
mysql-test/r/greedy_optimizer.result:
  Auto merged
mysql-test/r/index_merge.result:
  Auto merged
mysql-test/r/index_merge_bdb.result:
  Auto merged
mysql-test/r/index_merge_innodb.result:
  Auto merged
mysql-test/r/index_merge_innodb2.result:
  Auto merged
mysql-test/r/index_merge_ror.result:
  Auto merged
mysql-test/r/index_merge_ror_cpk.result:
  Auto merged
mysql-test/r/join_nested.result:
  Auto merged
mysql-test/r/rowid_order_bdb.result:
  Auto merged
mysql-test/r/rowid_order_innodb.result:
  Auto merged
mysql-test/r/rpl_session_var.result:
  Auto merged
mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/sp-security.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/sum_distinct.result:
  Auto merged
mysql-test/std_data/des_key_file:
  Auto merged
mysql-test/std_data/init_file.dat:
  Auto merged
mysql-test/std_data/loaddata1.dat:
  Auto merged
mysql-test/std_data/loaddata2.dat:
  Auto merged
mysql-test/std_data/loaddata3.dat:
  Auto merged
mysql-test/std_data/loaddata4.dat:
  Auto merged
mysql-test/std_data/rpl_loaddata.dat:
  Auto merged
mysql-test/std_data/rpl_loaddata2.dat:
  Auto merged
mysql-test/std_data/warnings_loaddata.dat:
  Auto merged
mysql-test/t/greedy_optimizer.test:
  Auto merged
mysql-test/t/index_merge.test:
  Auto merged
mysql-test/t/index_merge_bdb.test:
  Auto merged
mysql-test/t/index_merge_innodb.test:
  Auto merged
mysql-test/t/index_merge_innodb2.test:
  Auto merged
mysql-test/t/index_merge_ror.test:
  Auto merged
mysql-test/t/index_merge_ror_cpk.test:
  Auto merged
mysql-test/t/join_nested.test:
  Auto merged
mysql-test/t/rowid_order_bdb.test:
  Auto merged
mysql-test/t/rowid_order_innodb.test:
  Auto merged
mysql-test/t/rpl_session_var.test:
  Auto merged
mysql-test/t/sp-error.test:
  Auto merged
mysql-test/t/sp-security.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/sum_distinct.test:
  Auto merged
sql/log.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
This commit is contained in:
unknown 2005-10-17 19:09:12 +04:00
commit b63b06dcbb
4 changed files with 114 additions and 7 deletions

View file

@ -358,7 +358,7 @@ MYSQL_LOG::MYSQL_LOG()
:bytes_written(0), last_time(0), query_start(0), name(0),
file_id(1), open_count(1), log_type(LOG_CLOSED), write_error(0), inited(0),
need_start_event(1), prepared_xids(0), description_event_for_exec(0),
description_event_for_queue(0)
description_event_for_queue(0), readers_count(0), reset_pending(false)
{
/*
We don't want to initialize LOCK_Log here as such initialization depends on
@ -384,7 +384,9 @@ void MYSQL_LOG::cleanup()
delete description_event_for_exec;
(void) pthread_mutex_destroy(&LOCK_log);
(void) pthread_mutex_destroy(&LOCK_index);
(void) pthread_mutex_destroy(&LOCK_readers);
(void) pthread_cond_destroy(&update_cond);
(void) pthread_cond_destroy(&reset_cond);
}
DBUG_VOID_RETURN;
}
@ -429,7 +431,9 @@ void MYSQL_LOG::init_pthread_objects()
inited= 1;
(void) pthread_mutex_init(&LOCK_log,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_readers, MY_MUTEX_INIT_SLOW);
(void) pthread_cond_init(&update_cond, 0);
(void) pthread_cond_init(&reset_cond, 0);
}
const char *MYSQL_LOG::generate_name(const char *log_name,
@ -932,6 +936,13 @@ bool MYSQL_LOG::reset_logs(THD* thd)
*/
pthread_mutex_lock(&LOCK_log);
pthread_mutex_lock(&LOCK_index);
/*
we need one more lock to block attempts to open a log while
we are waiting untill all log files will be closed
*/
pthread_mutex_lock(&LOCK_readers);
/*
The following mutex is needed to ensure that no threads call
'delete thd' as we would then risk missing a 'rollback' from this
@ -954,6 +965,19 @@ bool MYSQL_LOG::reset_logs(THD* thd)
goto err;
}
reset_pending = true;
/*
send update signal just in case so that all reader threads waiting
for log update will leave wait condition
*/
signal_update();
/*
if there are active readers wait until all of them will
release opened files
*/
if (readers_count)
pthread_cond_wait(&reset_cond, &LOCK_log);
for (;;)
{
my_delete(linfo.log_file_name, MYF(MY_WME));
@ -972,7 +996,10 @@ bool MYSQL_LOG::reset_logs(THD* thd)
my_free((gptr) save_name, MYF(0));
err:
reset_pending = false;
(void) pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_unlock(&LOCK_readers);
pthread_mutex_unlock(&LOCK_index);
pthread_mutex_unlock(&LOCK_log);
DBUG_RETURN(error);
@ -2045,6 +2072,10 @@ void MYSQL_LOG::wait_for_update(THD* thd, bool is_slave)
{
const char *old_msg;
DBUG_ENTER("wait_for_update");
if (reset_pending)
DBUG_VOID_RETURN;
old_msg= thd->enter_cond(&update_cond, &LOCK_log,
is_slave ?
"Has read all relay log; waiting for the slave I/O "
@ -2295,6 +2326,32 @@ void MYSQL_LOG::signal_update()
DBUG_VOID_RETURN;
}
void MYSQL_LOG::readers_addref()
{
/*
There is no necessity for reference counting on *nix, since it allows to
delete opened files, however it is more clean way to wait
untill all files will be closed on *nix as well.
*/
DBUG_ENTER("MYSQL_LOG::reader_addref");
pthread_mutex_lock(&LOCK_log);
pthread_mutex_lock(&LOCK_readers);
readers_count++;
pthread_mutex_unlock(&LOCK_readers);
pthread_mutex_unlock(&LOCK_log);
DBUG_VOID_RETURN;
}
void MYSQL_LOG::readers_release()
{
DBUG_ENTER("MYSQL_LOG::reader_release");
pthread_mutex_lock(&LOCK_log);
readers_count--;
if (!readers_count)
pthread_cond_broadcast(&reset_cond);
pthread_mutex_unlock(&LOCK_log);
DBUG_VOID_RETURN;
}
#ifdef __NT__
void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,