Commit 0820d47f authored by unknown's avatar unknown

open binlog index file *before* tc_log->open() and binlog itself *after*


sql/mysql_priv.h:
  checkpoint: open_log() removed
sql/sql_yacc.yy:
  checkpoint: open_log() removed
sql/log.cc:
  split the opening of the .index file and binlog itself - now they are done by separate functions
sql/slave.cc:
  init_relay_log_info() made static
  split the opening of the .index file and binlog itself - now they are done by separate functions
sql/slave.h:
  init_relay_log_info() made static
sql/sql_class.h:
  split the opening of the .index file and binlog itself - now they are done by separate functions
parent 5c3ee996
This diff is collapsed.
......@@ -930,11 +930,6 @@ void sql_print_information(const char *format, ...);
bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension);
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append,
bool no_auto_events, ulong max_size);
File open_binlog(IO_CACHE *log, const char *log_file_name,
const char **errmsg);
handlerton *binlog_init();
......
......@@ -2289,45 +2289,14 @@ extern "C" pthread_handler_decl(handle_shutdown,arg)
#endif
const char *load_default_groups[]= {
const char *load_default_groups[]= {
#ifdef HAVE_NDBCLUSTER_DB
"mysql_cluster",
#endif
"mysqld","server",MYSQL_BASE_VERSION,0,0};
"mysqld","server", MYSQL_BASE_VERSION, 0, 0};
static const int load_default_groups_sz=
sizeof(load_default_groups)/sizeof(load_default_groups[0]);
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append,
bool no_auto_events, ulong max_size)
{
char tmp[FN_REFLEN];
if (!opt_name || !opt_name[0])
{
/*
TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(tmp,hostname,FN_REFLEN-5);
strmov(fn_ext(tmp),extension);
opt_name=tmp;
}
// get rid of extension if the log is binary to avoid problems
if (type == LOG_BIN)
{
char *p = fn_ext(opt_name);
uint length=(uint) (p-opt_name);
strmake(tmp,opt_name,min(length,FN_REFLEN));
opt_name=tmp;
}
return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
no_auto_events, max_size, 0);
}
/*
Initialize one of the global date/time format variables
......@@ -2335,7 +2304,7 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
init_global_datetime_format()
format_type What kind of format should be supported
var_ptr Pointer to variable that should be updated
NOTES
The default value is taken from either opt_date_time_formats[] or
the ISO format (ANSI SQL)
......@@ -2617,8 +2586,7 @@ static int init_server_components()
#endif
/* Setup log files */
if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
LOG_NORMAL, 0, 0, 0);
mysql_log.open_query_log(opt_logname);
if (opt_update_log)
{
/*
......@@ -2671,20 +2639,13 @@ version 5.0 and above. It is replaced by the binary log. Now starting MySQL \
with --log-bin instead.");
}
}
if (opt_bin_log)
{
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name, LOG_BIN, 0, 0, max_binlog_size);
using_update_log=1;
}
else if (opt_log_slave_updates)
if (opt_log_slave_updates && !opt_bin_log)
sql_print_warning("\
you need to use --log-bin to make --log-slave-updates work. \
You need to use --log-bin to make --log-slave-updates work. \
Now disabling --log-slave-updates.");
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
NullS, LOG_NORMAL, 0, 0, 0);
mysql_slow_log.open_slow_log(opt_slow_logname);
#ifdef HAVE_REPLICATION
if (opt_log_slave_updates && replicate_same_server_id)
......@@ -2716,12 +2677,25 @@ server.");
}
}
if (opt_bin_log)
{
char buf[FN_REFLEN];
const char *ln;
ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
if (ln == buf)
{
my_free(opt_bin_logname, MYF(0));
opt_bin_logname=my_strdup(buf, MYF(0));
}
mysql_bin_log.open_index_file(opt_binlog_index_name, ln);
using_update_log=1;
}
if (ha_init())
{
sql_print_error("Can't init databases");
unireg_abort(1);
}
tc_log= total_ha_2pc > 1 ? opt_bin_log ?
(TC_LOG *)&mysql_bin_log :
(TC_LOG *)&tc_log_mmap :
......@@ -2733,6 +2707,10 @@ server.");
unireg_abort(1);
}
if (opt_bin_log)
mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
WRITE_CACHE, 0, max_binlog_size, 0);
#ifdef HAVE_REPLICATION
if (opt_bin_log && expire_logs_days)
{
......
This diff is collapsed.
/* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
......@@ -366,11 +366,11 @@ typedef struct st_master_info
my_bool ssl; // enables use of SSL connection if true
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
my_off_t master_log_pos;
File fd; // we keep the file open, so we need to remember the file pointer
IO_CACHE file;
pthread_mutex_t data_lock,run_lock;
pthread_cond_t data_cond,start_cond,stop_cond;
THD *io_thd;
......@@ -385,7 +385,7 @@ typedef struct st_master_info
bool inited;
volatile bool abort_slave, slave_running;
volatile ulong slave_run_id;
/*
/*
The difference in seconds between the clock of the master and the clock of
the slave (second - first). It must be signed as it may be <0 or >0.
clock_diff_with_master is computed when the I/O thread starts; for this the
......@@ -394,8 +394,8 @@ typedef struct st_master_info
clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
*/
long clock_diff_with_master;
long clock_diff_with_master;
st_master_info()
:ssl(0), fd(-1), io_thd(0), inited(0),
abort_slave(0),slave_running(0), slave_run_id(0)
......@@ -403,7 +403,7 @@ typedef struct st_master_info
host[0] = 0; user[0] = 0; password[0] = 0;
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
ssl_cipher[0]= 0; ssl_key[0]= 0;
bzero((char*) &file, sizeof(file));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
......@@ -523,7 +523,6 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
bool abort_if_no_master_info_file,
int thread_mask);
void end_master_info(MASTER_INFO* mi);
int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname);
void end_relay_log_info(RELAY_LOG_INFO* rli);
void lock_slave_threads(MASTER_INFO* mi);
void unlock_slave_threads(MASTER_INFO* mi);
......
......@@ -255,7 +255,7 @@ class MYSQL_LOG: public TC_LOG
{
#ifndef DBUG_OFF
char buf1[22],buf2[22];
#endif
#endif
DBUG_ENTER("harvest_bytes_written");
(*counter)+=bytes_written;
DBUG_PRINT("info",("counter: %s bytes_written: %s", llstr(*counter,buf1),
......@@ -272,11 +272,29 @@ class MYSQL_LOG: public TC_LOG
bool no_auto_events_arg, ulong max_size);
void init_pthread_objects();
void cleanup();
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
bool open(const char *log_name,
enum_log_type log_type,
const char *new_name,
enum cache_type io_cache_type_arg,
bool no_auto_events_arg, ulong max_size,
bool null_created);
const char *generate_name(const char *log_name, const char *suffix,
bool strip_ext, char *buff);
/* simplified open_xxx wrappers for the gigantic open above */
bool open_query_log(const char *log_name)
{
char buf[FN_REFLEN];
return open(generate_name(log_name, ".log", 0, buf),
LOG_NORMAL, 0, WRITE_CACHE, 0, 0, 0);
}
bool open_slow_log(const char *log_name)
{
char buf[FN_REFLEN];
return open(generate_name(log_name, "-slow.log", 0, buf),
LOG_NORMAL, 0, WRITE_CACHE, 0, 0, 0);
}
bool open_index_file(const char *index_file_name_arg,
const char *log_name);
void new_file(bool need_lock= 1);
bool write(THD *thd, enum enum_server_command command,
const char *format,...);
......@@ -291,7 +309,7 @@ class MYSQL_LOG: public TC_LOG
*/
bool appendv(const char* buf,uint len,...);
bool append(Log_event* ev);
int generate_new_name(char *new_name,const char *old_name);
void make_log_name(char* buf, const char* log_ident);
bool is_active(const char* log_file_name);
......
......@@ -8052,7 +8052,7 @@ xa: XA_SYM begin_or_start xid opt_join_or_resume
;
xid: ident_or_text { Lex->ident=$1; }
;
;
begin_or_start: BEGIN_SYM {}
| START_SYM {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment