List:Commits« Previous MessageNext Message »
From:Luís Soares Date:January 14 2011 5:29pm
Subject:Re: bzr commit into mysql-trunk branch (hezx:3481) Bug#12133
View as plain text  
On 01/14/2011 04:00 PM, Luís Soares wrote:
>
> Hi Zhenxing,
>
> Nice Work. I don't have much to say about the server
> changes. However, I have some recommendations for the test
> case. Please find my review comments below.
>
> Finally, and FYI, I think that this patch also fixes BUG#55460
> (there might be others, eg: BUG#42879 and BUG#57771), wouldn't you
> say so ?
>
> Regards,
> Luís
>
>
> STATUS
> ------
>
> Patch not approved.
>
> REQUIRED CHANGES
> ----------------
>
> RC1. In rpl_binlog_index.test
>
> +--let $tmpdir= $MYSQLTEST_VARDIR/tmp/rpl_binlog_index
>
> I would create an unique tmp name for the directory (in case
> this test would be executed in parallel that would avoid name
> collisions). However, I don't think this is necessary, because
> the test case has to run only once - which is not the case in
> your patch. So I suggest you add right after source
> include/master-slave.inc; the following line:
>
> source include/have_binlog_format_row.inc;
>
> RC1. In rpl_binlog_index.test
>
> I think you can use rpl_stop_server.inc, rpl_start_server.inc
> instead of manually stopping and starting the servers.

Hmm... maybe you cannot because you have to set
different restart options from the default ones.

Right ?


> RC3. In rpl_binlog_index.test
>
> +INSERT INTO t1 VALUES (2);
> +SELECT * FROM t1;
> +sync_slave_with_master;
> +SELECT * FROM t1;
>
> It's probably better that you use include/diff_tables instead.
>
>
> REQUESTS
> --------
> n/a
>
> SUGGESTIONS
> -----------
> n/a
>
> DETAILS
> -------
> n/a
>
> On 01/12/2011 05:43 AM, He Zhenxing wrote:
>> #At file:///media/sdb2/hezx/work/mysql/bzr/b12133/trunk/ based on
>> revid:mattias.jonsson@stripped
>>
>> 3481 He Zhenxing 2011-01-12
>> BUG#12133 master.index file keeps mysqld from starting if bin log has been moved
>>
>> Absolute path or relative path to the data directory was recorded
>> in the binlog or relay log index files, which caused the server
>> unable to locate the log files and failed to start when user moved
>> the binlog or relay log files to another directory and restart the
>> server with binlog or relay log option set to the new path.
>>
>> Fixed the problem by only record the basename in the binlog or relay
>> log index files, and use the directory of the binlog or relay log
>> option to calculate the path to access the log files.
>>
>> When reading an index file that was generated by a server before
>> the fix, the directory part will be stripped before calculating
>> the path.
>> @ mysql-test/include/setup_fake_relay_log.inc
>> After fix of BUG#12133, there is no need to prepend ./ or .\ for
>> filenames in the binlog or relay log index file.
>> @ mysql-test/suite/rpl/t/rpl_manual_change_index_file.test
>> After fix of BUG#12133, there is no need to prepend ./ or .\ for
>> filenames in the binlog or relay log index file.
>>
>> added:
>> mysql-test/suite/rpl/r/rpl_binlog_index.result
>> mysql-test/suite/rpl/t/rpl_binlog_index.test
>> modified:
>> mysql-test/include/setup_fake_relay_log.inc
>> mysql-test/suite/rpl/t/rpl_manual_change_index_file.test
>> sql/binlog.cc
>> sql/rpl_master.cc
>> sql/rpl_rli.cc
>> sql/rpl_slave.cc
>> === modified file 'mysql-test/include/setup_fake_relay_log.inc'
>> --- a/mysql-test/include/setup_fake_relay_log.inc 2010-12-19 17:22:30 +0000
>> +++ b/mysql-test/include/setup_fake_relay_log.inc 2011-01-12 05:43:32 +0000
>> @@ -80,19 +80,7 @@ RESET SLAVE;
>>
>> # Create relay log index.
>>
>> -# After patch for BUG#12190, the filename used in CHANGE MASTER
>> -# RELAY_LOG_FILE will be automatically added the directory of the
>> -# relay log before comparison, thus we need to added the directory
>> -# part (./ on unix .\ on windows) when faking the relay-log-bin.index.
>> -
>> -# mysqltest currently parses backslash escapes wrong, so any sequence
>> -# of N backslashes is collapsed to just one backslash. So we use the
>> -# SQL function CHAR() to generate a backslash character instead. Since
>> -# the string is interpreted in SQL context, we to escape it, so we use
>> -# two backslashes.
>> -
>> ---let $_fake_dir= `select IF(convert(@@version_compile_os using latin1) IN
> ("Win32","Win64","Windows"), CONCAT('.',
>> CHAR(92), CHAR(92)), './')`
>> ---let $write_var= $_fake_dir$_fake_filename-fake.000001\n
>> +--let $write_var= $_fake_filename-fake.000001\n
>> --let $write_to_file= $_fake_relay_index
>> --source include/write_var_to_file.inc
>>
>>
>> === added file 'mysql-test/suite/rpl/r/rpl_binlog_index.result'
>> --- a/mysql-test/suite/rpl/r/rpl_binlog_index.result 1970-01-01 00:00:00 +0000
>> +++ b/mysql-test/suite/rpl/r/rpl_binlog_index.result 2011-01-12 05:43:32 +0000
>> @@ -0,0 +1,24 @@
>> +include/master-slave.inc
>> +[connection master]
>> +CREATE TABLE t1 (a INT);
>> +INSERT INTO t1 VALUES (1);
>> +# Shutdown master
>> +# Move the master binlog files and the index file to a new place
>> +# Restart master with log-bin option set to the new path
>> +# Master has restarted successfully
>> +include/stop_slave.inc
>> +# Move the slave binlog and relay log files and index to the new place
>> +# Shutdown slave
>> +# Restart slave with options log-bin, relay-log set to the new paths
>> +# Slave has restarted successfully
>> +include/start_slave.inc
>> +INSERT INTO t1 VALUES (2);
>> +SELECT * FROM t1;
>> +a
>> +1
>> +2
>> +SELECT * FROM t1;
>> +a
>> +1
>> +2
>> +DROP TABLE t1;
>>
>> === added file 'mysql-test/suite/rpl/t/rpl_binlog_index.test'
>> --- a/mysql-test/suite/rpl/t/rpl_binlog_index.test 1970-01-01 00:00:00 +0000
>> +++ b/mysql-test/suite/rpl/t/rpl_binlog_index.test 2011-01-12 05:43:32 +0000
>> @@ -0,0 +1,125 @@
>> +# ==== Purpose ====
>> +#
>> +# Test that server can work fine after moving binlog or relay log
>> +# files to another directory and setting binlog or relay log paths to
>> +# the new path.
>> +#
>> +# ==== Method ====
>> +#
>> +# Start replication, and then shutdown the master, move the binary
>> +# logs and the log index file to a another directory and then restart
>> +# the server with option to set the new binlog directory. After master
>> +# restarted successfully, do the similar on slave to check the relay
>> +# log of slave.
>> +#
>> +# ==== Reference ====
>> +#
>> +# BUG#12133 master.index file keeps mysqld from starting if bin log has been
> moved
>> +# BUG#42576 Relay logs in relay-log.info&localhost-relay-bin.index not
> processed after move
>> +
>> +source include/master-slave.inc;
>> +
>> +connection master;
>> +--let $master_datadir= `select @@datadir`
>> +connection slave;
>> +--let $slave_datadir= `select @@datadir`
>> +connection master;
>> +--let $tmpdir= $MYSQLTEST_VARDIR/tmp/rpl_binlog_index
>> +--mkdir $tmpdir
>> +
>> +CREATE TABLE t1 (a INT);
>> +INSERT INTO t1 VALUES (1);
>> +
>> +sync_slave_with_master;
>> +
>> +#
>> +# Test on master
>> +#
>> +connection master;
>> +--echo # Shutdown master
>> +# Write file to make mysql-test-run.pl expect the "crash", but don't start
>> +# it until it's told to
>> +--exec echo "wait"> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
>> +
>> +# Send shutdown to the connected server and give
>> +# it 10 seconds to die before zapping it
>> +shutdown_server 10;
>> +
>> +--echo # Move the master binlog files and the index file to a new place
>> +--move_file $master_datadir/master-bin.000001 $tmpdir/master-bin.000001
>> +--move_file $master_datadir/master-bin.index $tmpdir/master-bin.index
>> +
>> +--echo # Restart master with log-bin option set to the new path
>> +--exec echo 'restart: --log-bin=$tmpdir/master-bin'>
> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
>> +
>> +# Turn on reconnect
>> +--enable_reconnect
>> +
>> +# Call script that will poll the server waiting for it to be back online again
>> +--source include/wait_until_connected_again.inc
>> +
>> +# Turn off reconnect again
>> +--disable_reconnect
>> +
>> +--echo # Master has restarted successfully
>> +
>> +connection slave;
>> +source include/stop_slave.inc;
>> +
>> +--disable_query_log
>> +# slave-relay-bin.* files can vary, so read the slave-relay-bin.index
>> +# to figure out the slave-relay-bin.* files
>> +CREATE TEMPORARY TABLE tmp (id INT AUTO_INCREMENT PRIMARY KEY, filename
> VARCHAR(1024));
>> +# chmod to allow the following LOAD DATA
>> +--chmod 0666 $slave_datadir/slave-relay-bin.index
>> +--eval LOAD DATA INFILE '$slave_datadir/slave-relay-bin.index' INTO TABLE tmp
> (filename)
>> +--let $count= `SELECT count(*) FROM tmp`
>> +--echo # Move the slave binlog and relay log files and index to the new place
>> +--move_file $slave_datadir/slave-bin.index $tmpdir/slave-bin.index
>> +--move_file $slave_datadir/slave-bin.000001 $tmpdir/slave-bin.000001
>> +--move_file $slave_datadir/slave-relay-bin.index $tmpdir/slave-relay-bin.index
>> +while ($count)
>> +{
>> + --let $filename= `select filename from tmp where id=$count`
>> + --move_file $slave_datadir/$filename $tmpdir/$filename
>> + --dec $count
>> +}
>> +DROP TEMPORARY TABLE tmp;
>> +--enable_query_log
>> +
>> +--echo # Shutdown slave
>> +# Write file to make mysql-test-run.pl expect the "crash", but don't start
>> +# it until it's told to
>> +--exec echo "wait"> $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
>> +
>> +# Send shutdown to the connected server and give
>> +# it 10 seconds to die before zapping it
>> +shutdown_server 10;
>> +
>> +--echo # Restart slave with options log-bin, relay-log set to the new paths
>> +--exec echo 'restart: --log-bin=$tmpdir/slave-bin
> --relay-log=$tmpdir/slave-relay-bin'>
>> $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
>> +
>> +# Turn on reconnect
>> +--enable_reconnect
>> +
>> +# Call script that will poll the server waiting for it to be back online again
>> +--source include/wait_until_connected_again.inc
>> +
>> +# Turn off reconnect again
>> +--disable_reconnect
>> +
>> +--echo # Slave has restarted successfully
>> +source include/start_slave.inc;
>> +
>> +connection master;
>> +
>> +INSERT INTO t1 VALUES (2);
>> +SELECT * FROM t1;
>> +sync_slave_with_master;
>> +SELECT * FROM t1;
>> +
>> +connection master;
>> +DROP TABLE t1;
>> +sync_slave_with_master;
>> +--remove_files_wildcard $tmpdir *
>> +--rmdir $tmpdir
>>
>> === modified file 'mysql-test/suite/rpl/t/rpl_manual_change_index_file.test'
>> --- a/mysql-test/suite/rpl/t/rpl_manual_change_index_file.test 2010-12-19
> 17:22:30 +0000
>> +++ b/mysql-test/suite/rpl/t/rpl_manual_change_index_file.test 2011-01-12
> 05:43:32 +0000
>> @@ -11,8 +11,8 @@ source include/master-slave.inc;
>>
>> FLUSH LOGS;
>> # Now, 2 entries in index file.
>> -# ./master-bin.000001
>> -# ./master-bin.000002
>> +# master-bin.000001
>> +# master-bin.000002
>>
>> CREATE TABLE t1(c1 INT);
>> # Now, the current dump file(master-bin.000002) is the second line of index
>> @@ -23,34 +23,23 @@ sync_slave_with_master;
>> # events.
>>
>> connection master;
>> -# Delete './master-bin.000001' from index file.
>> +# Delete 'master-bin.000001' from index file.
>> let $MYSQLD_DATADIR= `SELECT @@DATADIR`;
>> let $file= $MYSQLD_DATADIR/master-bin.index;
>> source include/truncate_file.inc;
>>
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> append_file $MYSQLD_DATADIR/master-bin.index;
>> -./master-bin.000002
>> +master-bin.000002
>> EOF
>> sleep 0.00000001;
>> -}
>> -
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> -append_file $MYSQLD_DATADIR/master-bin.index;
>> -.\master-bin.000002
>> -EOF
>> -sleep 0.00000001;
>> -}
>>
>> # Now, only 1 entry in index file. ./master-bin.000002
>>
>> # Generate master-bin.000003, but it is in the second line.
>> FLUSH LOGS;
>> # Now, 2 entries in index file.
>> -# ./master-bin.000002
>> -# ./master-bin.000003
>> +# master-bin.000002
>> +# master-bin.000003
>>
>> # Now, master know that new binlog file(master-bin.000003) has been generated.
>> # It expects that the new binlog file is in third line of index file, but
>> @@ -67,25 +56,12 @@ connection master;
>>
>> source include/truncate_file.inc;
>>
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> append_file $MYSQLD_DATADIR/master-bin.index;
>> -./master-bin.000001
>> -./master-bin.000002
>> -./master-bin.000003
>> +master-bin.000001
>> +master-bin.000002
>> +master-bin.000003
>> EOF
>> sleep 0.00000001;
>> -}
>> -
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> -append_file $MYSQLD_DATADIR/master-bin.index;
>> -.\master-bin.000001
>> -.\master-bin.000002
>> -.\master-bin.000003
>> -EOF
>> -sleep 0.00000001;
>> -}
>>
>> CREATE TABLE t2(c1 INT);
>> FLUSH LOGS;
>> @@ -138,20 +114,11 @@ connection master;
>> PURGE MASTER LOGS TO 'master-bin.000003';
>>
>> --echo # Re-insert master-bin.000002 into index file manually.
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> append_file $MASTER_DATADIR/master-bin.index;
>> -./master-bin.000002
>> +master-bin.000002
>> EOF
>> sleep 0.00000001;
>> -}
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> -append_file $MASTER_DATADIR/master-bin.index;
>> -.\master-bin.000002
>> -EOF
>> -sleep 0.00000001;
>> -}
>> +
>> --echo # PURGE is used to update IO_CACHE of index file. After this statement,
>> --echo # master knows that master-bin.000002 is in index file.
>> PURGE MASTER LOGS TO 'master-bin.000002';
>> @@ -176,20 +143,12 @@ connection master;
>> --echo # Restore the correct index file.
>> let $file= $MASTER_DATADIR/master-bin.index;
>> source include/truncate_file.inc;
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> -append_file $MASTER_DATADIR/master-bin.index;
>> -./master-bin.000003
>> -EOF
>> -sleep 0.00000001;
>> -}
>> -if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64',
> 'Windows')`)
>> -{
>> +
>> append_file $MASTER_DATADIR/master-bin.index;
>> -.\master-bin.000003
>> +master-bin.000003
>> EOF
>> sleep 0.00000001;
>> -}
>> +
>> FLUSH LOGS;
>> PURGE MASTER LOGS TO 'master-bin.000004';
>>
>>
>> === modified file 'sql/binlog.cc'
>> --- a/sql/binlog.cc 2010-12-17 02:01:32 +0000
>> +++ b/sql/binlog.cc 2011-01-12 05:43:32 +0000
>> @@ -42,6 +42,13 @@ static int binlog_commit(handlerton *hto
>> static int binlog_rollback(handlerton *hton, THD *thd, bool all);
>> static int binlog_prepare(handlerton *hton, THD *thd, bool all);
>>
>> +static inline bool same_log_name(const char* log_name1, const char* log_name2)
>> +{
>> + uint dir_len1= dirname_length(log_name1);
>> + uint dir_len2= dirname_length(log_name2);
>> + return !strcmp(log_name1 + dir_len1, log_name2 + dir_len2);
>> +}
>> +
>> /*
>> Helper class to hold a mutex for the duration of the
>> block.
>> @@ -1425,7 +1432,9 @@ bool show_binlog_events(THD *thd, MYSQL_
>> thd->current_linfo =&linfo;
>> mysql_mutex_unlock(&LOCK_thread_count);
>>
>> - if ((file=open_binlog(&log, linfo.log_file_name,&errmsg))< 0)
>> + char log_path[FN_REFLEN];
>> + binary_log->make_log_name(log_path, linfo.log_file_name);
>> + if ((file=open_binlog(&log, log_path,&errmsg))< 0)
>> goto err;
>>
>> /*
>> @@ -1473,7 +1482,7 @@ bool show_binlog_events(THD *thd, MYSQL_
>> description_event->checksum_alg= ev->checksum_alg;
>>
>> if (event_count>= limit_start&&
>> - ev->net_send(protocol, linfo.log_file_name, pos))
>> + ev->net_send(protocol, log_path, pos))
>> {
>> errmsg = "Net error";
>> delete ev;
>> @@ -1868,9 +1877,10 @@ bool MYSQL_BIN_LOG::open(const char *log
>> As this is a new log file, we write the file name to the index
>> file. As every time we write to the index file, we sync it.
>> */
>> + char *log_basename= log_file_name + dirname_length(log_file_name);
>> if (DBUG_EVALUATE_IF("fault_injection_updating_index", 1, 0) ||
>> - my_b_write(&index_file, (uchar*) log_file_name,
>> - strlen(log_file_name)) ||
>> + my_b_write(&index_file, (uchar*) log_basename,
>> + strlen(log_basename)) ||
>> my_b_write(&index_file, (uchar*) "\n", 1) ||
>> flush_io_cache(&index_file) ||
>> mysql_file_sync(index_file.file, MYF(MY_WME)))
>> @@ -2003,6 +2013,9 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO
>> int error= 0;
>> char *fname= linfo->log_file_name;
>> uint log_name_len= log_name ? (uint) strlen(log_name) : 0;
>> + uint log_dir_len= log_name ? dirname_length(log_name) : 0;
>> + const char *log_basename= log_name + log_dir_len;
>> + uint log_basename_len= log_name_len - log_dir_len;
>> DBUG_ENTER("find_log_pos");
>> DBUG_PRINT("enter",("log_name: %s", log_name ? log_name : "NULL"));
>>
>> @@ -2032,10 +2045,23 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO
>> break;
>> }
>>
>> + const char *log_name_tmp;
>> + uint log_name_len_tmp;
>> + if (dirname_length(fname))
>> + {
>> + log_name_tmp= log_name;
>> + log_name_len_tmp= log_name_len;
>> + }
>> + else
>> + {
>> + log_name_tmp= log_basename;
>> + log_name_len_tmp= log_basename_len;
>> + }
>> +
>> // if the log entry matches, null string matching anything
>> if (!log_name ||
>> - (log_name_len == length-1&& fname[log_name_len] == '\n'&&
>> - !memcmp(fname, log_name, log_name_len)))
>> + (log_name_len_tmp == length-1&& fname[log_name_len_tmp] ==
> '\n'&&
>> + !memcmp(fname, log_name_tmp, log_name_len_tmp)))
>> {
>> DBUG_PRINT("info",("Found log file entry"));
>> fname[length-1]=0; // remove last \n
>> @@ -2172,7 +2198,9 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
>>
>> for (;;)
>> {
>> - if ((error= my_delete_allow_opened(linfo.log_file_name, MYF(0))) != 0)
>> + char log_name[FN_REFLEN];
>> + make_log_name(log_name, linfo.log_file_name);
>> + if ((error= my_delete_allow_opened(log_name, MYF(0))) != 0)
>> {
>> if (my_errno == ENOENT)
>> {
>> @@ -2296,7 +2324,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay
>>
>> DBUG_ASSERT(is_open());
>> DBUG_ASSERT(rli->slave_running == 1);
>> -
> DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->get_event_relay_log_name()));
>> +
> DBUG_ASSERT(same_log_name(rli->linfo.log_file_name,rli->get_event_relay_log_name()));
>>
>> mysql_mutex_assert_owner(&rli->data_lock);
>>
>> @@ -2453,7 +2481,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
>> */
>> if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/)))
>> goto err;
>> - while ((strcmp(to_log,log_info.log_file_name) ||
> (exit_loop=included))&&
>> + while ((!same_log_name(to_log,log_info.log_file_name) ||
> (exit_loop=included))&&
>> !is_active(log_info.log_file_name)&&
>> !log_in_use(log_info.log_file_name))
>> {
>> @@ -2806,12 +2834,13 @@ int MYSQL_BIN_LOG::purge_logs_before_dat
>> if ((error=find_log_pos(&log_info, NullS, 0 /*no mutex*/)))
>> goto err;
>>
>> - while (strcmp(log_file_name, log_info.log_file_name)&&
>> + while (!same_log_name(log_file_name, log_info.log_file_name)&&
>> !is_active(log_info.log_file_name)&&
>> !log_in_use(log_info.log_file_name))
>> {
>> - if (!mysql_file_stat(key_file_binlog,
>> - log_info.log_file_name,&stat_area, MYF(0)))
>> + char log_path[FN_REFLEN];
>> + make_log_name(log_path, log_info.log_file_name);
>> + if (!mysql_file_stat(key_file_binlog, log_path,&stat_area, MYF(0)))
>> {
>> if (my_errno == ENOENT)
>> {
>> @@ -2870,6 +2899,7 @@ err:
>> Create a new log file name.
>>
>> @param buf buf of at least FN_REFLEN where new name is stored
>> + @return buf
>>
>> @note
>> If file name will be longer then FN_REFLEN it will be truncated
>> @@ -2877,11 +2907,12 @@ err:
>>
>> void MYSQL_BIN_LOG::make_log_name(char* buf, const char* log_ident)
>> {
>> + const char* log_name= log_ident + dirname_length(log_ident);
>> uint dir_len = dirname_length(log_file_name);
>> if (dir_len>= FN_REFLEN)
>> dir_len=FN_REFLEN-1;
>> strnmov(buf, log_file_name, dir_len);
>> - strmake(buf+dir_len, log_ident, FN_REFLEN - dir_len -1);
>> + strmake(buf+dir_len, log_name, FN_REFLEN - dir_len -1);
>> }
>>
>>
>> @@ -2891,7 +2922,7 @@ void MYSQL_BIN_LOG::make_log_name(char*
>>
>> bool MYSQL_BIN_LOG::is_active(const char *log_file_name_arg)
>> {
>> - return !strcmp(log_file_name, log_file_name_arg);
>> + return same_log_name(log_file_name, log_file_name_arg);
>> }
>>
>>
>> @@ -4173,7 +4204,7 @@ int MYSQL_BIN_LOG::open(const char *opt_
>>
>> do
>> {
>> - strmake(log_name, log_info.log_file_name, sizeof(log_name)-1);
>> + make_log_name(log_name, log_info.log_file_name);
>> } while (!(error= find_next_log(&log_info, 1)));
>>
>> if (error != LOG_INFO_EOF)
>> @@ -4182,6 +4213,14 @@ int MYSQL_BIN_LOG::open(const char *opt_
>> goto err;
>> }
>>
>> + if (!dirname_length(log_name))
>> + {
>> + int dir_len= dirname_length(opt_name);
>> + if (dir_len>= FN_REFLEN)
>> + dir_len=FN_REFLEN-1;
>> + strmake(log_name+dir_len, log_name, FN_REFLEN - dir_len -1);
>> + strnmov(log_name, opt_name, dir_len);
>> + }
>> if ((file= open_binlog(&log, log_name,&errmsg))< 0)
>> {
>> sql_print_error("%s", errmsg);
>>
>> === modified file 'sql/rpl_master.cc'
>> --- a/sql/rpl_master.cc 2010-12-17 10:07:30 +0000
>> +++ b/sql/rpl_master.cc 2011-01-12 05:43:32 +0000
>> @@ -622,8 +622,7 @@ void mysql_binlog_send(THD* thd, char* l
>> ushort flags)
>> {
>> LOG_INFO linfo;
>> - char *log_file_name = linfo.log_file_name;
>> - char search_file_name[FN_REFLEN], *name;
>> + char log_file_name[FN_REFLEN], *name;
>>
>> ulong ev_offset;
>>
>> @@ -672,7 +671,7 @@ void mysql_binlog_send(THD* thd, char* l
>> heartbeat_ts=&heartbeat_buf;
>> set_timespec_nsec(*heartbeat_ts, 0);
>> coord=&coord_buf;
>> - coord->file_name= log_file_name; // initialization basing on what slave
> remembers
>> + coord->file_name= linfo.log_file_name; // points to the current binary log
> file name
>> coord->pos= pos;
>> }
>> sql_print_information("Start binlog_dump to slave_server(%d), pos(%s, %lu)",
>> @@ -706,9 +705,9 @@ void mysql_binlog_send(THD* thd, char* l
>> goto err;
>> }
>>
>> - name=search_file_name;
>> + name=log_file_name;
>> if (log_ident[0])
>> - mysql_bin_log.make_log_name(search_file_name, log_ident);
>> + mysql_bin_log.make_log_name(log_file_name, log_ident);
>> else
>> name=0; // Find first log
>>
>> @@ -725,6 +724,10 @@ void mysql_binlog_send(THD* thd, char* l
>> thd->current_linfo =&linfo;
>> mysql_mutex_unlock(&LOCK_thread_count);
>>
>> + if (!name)
>> + mysql_bin_log.make_log_name(log_file_name,
>> + linfo.log_file_name);
>> +
>> if ((file=open_binlog(&log, log_file_name,&errmsg))< 0)
>> {
>> my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
>> @@ -1001,7 +1004,7 @@ impossible position";
>> goto err;
>>
>> if (!(flags& BINLOG_DUMP_NON_BLOCK)&&
>> - mysql_bin_log.is_active(log_file_name))
>> + mysql_bin_log.is_active(linfo.log_file_name))
>> {
>> /*
>> Block until there is more data in the log
>> @@ -1178,7 +1181,7 @@ impossible position";
>> case 0:
>> break;
>> case LOG_INFO_EOF:
>> - if (mysql_bin_log.is_active(log_file_name))
>> + if (mysql_bin_log.is_active(linfo.log_file_name))
>> {
>> loop_breaker = (flags& BINLOG_DUMP_NON_BLOCK);
>> break;
>> @@ -1199,6 +1202,7 @@ impossible position";
>> if (reset_transmit_packet(thd, flags,&ev_offset,&errmsg))
>> goto err;
>>
>> + mysql_bin_log.make_log_name(log_file_name, linfo.log_file_name);
>> /*
>> Call fake_rotate_event() in case the previous log (the one which
>> we have just finished reading) did not contain a Rotate event
>> @@ -1215,9 +1219,7 @@ impossible position";
>> my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
>> goto err;
>> }
>> -
>> - if (coord)
>> - coord->file_name= log_file_name; // reset to the next
>> + DBUG_ASSERT(!coord || (coord->file_name == linfo.log_file_name));
>> }
>> }
>>
>>
>> === modified file 'sql/rpl_rli.cc'
>> --- a/sql/rpl_rli.cc 2010-12-21 09:33:41 +0000
>> +++ b/sql/rpl_rli.cc 2011-01-12 05:43:32 +0000
>> @@ -104,11 +104,13 @@ static inline int add_relay_log(Relay_lo
>> {
>> MY_STAT s;
>> DBUG_ENTER("add_relay_log");
>> - if (!mysql_file_stat(key_file_binlog,
>> - linfo->log_file_name,&s, MYF(0)))
>> + char log_name[FN_REFLEN];
>> +
>> + rli->relay_log.make_log_name(log_name, linfo->log_file_name);
>> + if (!mysql_file_stat(key_file_binlog, log_name,&s, MYF(0)))
>> {
>> sql_print_error("log %s listed in the index, but failed to stat",
>> - linfo->log_file_name);
>> + log_name);
>> DBUG_RETURN(1);
>> }
>> rli->log_space_total += s.st_size;
>> @@ -263,11 +265,12 @@ int Relay_log_info::init_relay_log_pos(c
>> }
>> else
>> {
>> + char log_name[FN_REFLEN];
>> + relay_log.make_log_name(log_name, linfo.log_file_name);
>> /*
>> Open the relay log and set cur_log to point at this one
>> */
>> - if ((cur_log_fd=open_binlog(&cache_buf,
>> - linfo.log_file_name,errmsg))< 0)
>> + if ((cur_log_fd=open_binlog(&cache_buf, log_name, errmsg))< 0)
>> goto err;
>> cur_log =&cache_buf;
>> }
>>
>> === modified file 'sql/rpl_slave.cc'
>> --- a/sql/rpl_slave.cc 2010-12-10 16:55:50 +0000
>> +++ b/sql/rpl_slave.cc 2011-01-12 05:43:32 +0000
>> @@ -4943,9 +4943,11 @@ static IO_CACHE *reopen_relay_log(Relay_
>> DBUG_ASSERT(rli->cur_log !=&rli->cache_buf);
>> DBUG_ASSERT(rli->cur_log_fd == -1);
>>
>> + char relay_log_name[FN_REFLEN];
>> + rli->relay_log.make_log_name(relay_log_name,
> rli->get_event_relay_log_name());
>> +
>> IO_CACHE *cur_log = rli->cur_log=&rli->cache_buf;
>> - if
> ((rli->cur_log_fd=open_binlog(cur_log,rli->get_event_relay_log_name(),
>> - errmsg))<0)
>> + if ((rli->cur_log_fd=open_binlog(cur_log, relay_log_name, errmsg))<0)
>> DBUG_RETURN(0);
>> /*
>> We want to start exactly where we was before:
>> @@ -5363,9 +5365,10 @@ static Log_event* next_event(Relay_log_i
>> sql_print_information("next log '%s' is not active",
>> rli->linfo.log_file_name);
>> #endif
>> + char log_name[FN_REFLEN];
>> + rli->relay_log.make_log_name(log_name, rli->linfo.log_file_name);
>> // open_binlog() will check the magic header
>> - if ((rli->cur_log_fd=open_binlog(cur_log,rli->linfo.log_file_name,
>> -&errmsg))<0)
>> + if ((rli->cur_log_fd=open_binlog(cur_log, log_name,&errmsg))<0)
>> goto err;
>> }
>> else
>>
>>
>>
>>
>>
>
>

Thread
bzr commit into mysql-trunk branch (hezx:3481) Bug#12133He Zhenxing12 Jan
  • Re: bzr commit into mysql-trunk branch (hezx:3481) Bug#12133Luís Soares14 Jan
    • Re: bzr commit into mysql-trunk branch (hezx:3481) Bug#12133Luís Soares14 Jan
      • Re: bzr commit into mysql-trunk branch (hezx:3481) Bug#12133He Zhenxing17 Jan
    • Re: bzr commit into mysql-trunk branch (hezx:3481) Bug#12133He Zhenxing17 Jan