Commit 64e43e1c authored by unknown's avatar unknown

Merge various replication-related patches into MariaDB 5.3:

 - MWL#116 Group commit
 - MWL#136 Enhancements for START TRANSACTION WITH CONSISTENT SNAPSHOT
 - MWL#47 Annotate_rows_log_event
 - MWL#163 innodb_release_locks_early
 - Percona patch enhancing row-based replication for tables with no primary key
parents 8b427b7d 86008e0c
...@@ -95,5 +95,6 @@ enum options_client ...@@ -95,5 +95,6 @@ enum options_client
OPT_REWRITE_DB, OPT_REWRITE_DB,
OPT_PLUGIN_DIR, OPT_PLUGIN_DIR,
OPT_DEFAULT_PLUGIN, OPT_DEFAULT_PLUGIN,
OPT_SKIP_ANNOTATE_ROWS_EVENTS,
OPT_MAX_CLIENT_OPTION /* should be always the last */ OPT_MAX_CLIENT_OPTION /* should be always the last */
}; };
...@@ -108,6 +108,7 @@ static ulonglong rec_count= 0; ...@@ -108,6 +108,7 @@ static ulonglong rec_count= 0;
static short binlog_flags = 0; static short binlog_flags = 0;
static MYSQL* mysql = NULL; static MYSQL* mysql = NULL;
static const char* dirname_for_local_load= 0; static const char* dirname_for_local_load= 0;
static bool opt_skip_annotate_rows_events= 0;
/** /**
Pointer to the Format_description_log_event of the currently active binlog. Pointer to the Format_description_log_event of the currently active binlog.
...@@ -129,6 +130,70 @@ enum Exit_status { ...@@ -129,6 +130,70 @@ enum Exit_status {
OK_STOP OK_STOP
}; };
/**
Pointer to the last read Annotate_rows_log_event. Having read an
Annotate_rows event, we should not print it immediatedly because all
subsequent rbr events can be filtered away, and have to keep it for a while.
Also because of that when reading a remote Annotate event we have to keep
its binary log representation in a separately allocated buffer.
*/
static Annotate_rows_log_event *annotate_event= NULL;
void free_annotate_event()
{
if (annotate_event)
{
delete annotate_event;
annotate_event= 0;
}
}
Log_event* read_remote_annotate_event(uchar* net_buf, ulong event_len,
const char **error_msg)
{
uchar *event_buf;
Log_event* event;
if (!(event_buf= (uchar*) my_malloc(event_len + 1, MYF(MY_WME))))
{
error("Out of memory");
return 0;
}
memcpy(event_buf, net_buf, event_len);
event_buf[event_len]= 0;
if (!(event= Log_event::read_log_event((const char*) event_buf, event_len,
error_msg, glob_description_event)))
{
my_free(event_buf, MYF(0));
return 0;
}
/*
Ensure the event->temp_buf is pointing to the allocated buffer.
(TRUE = free temp_buf on the event deletion)
*/
event->register_temp_buf((char*)event_buf, TRUE);
return event;
}
void keep_annotate_event(Annotate_rows_log_event* event)
{
free_annotate_event();
annotate_event= event;
}
void print_annotate_event(PRINT_EVENT_INFO *print_event_info)
{
if (annotate_event)
{
annotate_event->print(result_file, print_event_info);
delete annotate_event; // the event should not be printed more than once
annotate_event= 0;
}
}
static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
const char* logname); const char* logname);
static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
...@@ -783,8 +848,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, ...@@ -783,8 +848,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
case QUERY_EVENT: case QUERY_EVENT:
{ {
Query_log_event *qe= (Query_log_event*)ev; Query_log_event *qe= (Query_log_event*)ev;
if (!qe->is_trans_keyword() && shall_skip_database(qe->db)) if (!qe->is_trans_keyword())
goto end; {
if (shall_skip_database(qe->db))
goto end;
}
else
{
/*
In case the event for one of these statements is obtained
from binary log 5.0, make it compatible with 5.1
*/
qe->flags|= LOG_EVENT_SUPPRESS_USE_F;
}
print_use_stmt(print_event_info, qe); print_use_stmt(print_event_info, qe);
if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS) if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
{ {
...@@ -933,6 +1009,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, ...@@ -933,6 +1009,19 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
my_free(fname, MYF(MY_WME)); my_free(fname, MYF(MY_WME));
break; break;
} }
case ANNOTATE_ROWS_EVENT:
if (!opt_skip_annotate_rows_events)
{
/*
We don't print Annotate event just now because all subsequent
rbr-events can be filtered away. Instead we'll keep the event
till it will be printed together with the first not filtered
away Table map or the last rbr will be processed.
*/
keep_annotate_event((Annotate_rows_log_event*) ev);
destroy_evt= FALSE;
}
break;
case TABLE_MAP_EVENT: case TABLE_MAP_EVENT:
{ {
Table_map_log_event *map= ((Table_map_log_event *)ev); Table_map_log_event *map= ((Table_map_log_event *)ev);
...@@ -942,6 +1031,13 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, ...@@ -942,6 +1031,13 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
destroy_evt= FALSE; destroy_evt= FALSE;
goto end; goto end;
} }
/*
The Table map is to be printed, so it's just the time when we may
print the kept Annotate event (if there is any).
print_annotate_event() also deletes the kept Annotate event.
*/
print_annotate_event(print_event_info);
size_t len_to= 0; size_t len_to= 0;
const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(), &len_to); const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(), &len_to);
if (len_to && map->rewrite_db(db_to, len_to, glob_description_event)) if (len_to && map->rewrite_db(db_to, len_to, glob_description_event))
...@@ -978,6 +1074,13 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, ...@@ -978,6 +1074,13 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
if (print_event_info->m_table_map_ignored.count() > 0) if (print_event_info->m_table_map_ignored.count() > 0)
print_event_info->m_table_map_ignored.clear_tables(); print_event_info->m_table_map_ignored.clear_tables();
/*
If there is a kept Annotate event and all corresponding
rbr-events were filtered away, the Annotate event was not
freed and it is just the time to do it.
*/
free_annotate_event();
/* /*
One needs to take into account an event that gets One needs to take into account an event that gets
filtered but was last event in the statement. If this is filtered but was last event in the statement. If this is
...@@ -1212,6 +1315,11 @@ that may lead to an endless loop.", ...@@ -1212,6 +1315,11 @@ that may lead to an endless loop.",
"Updates to a database with a different name than the original. \ "Updates to a database with a different name than the original. \
Example: rewrite-db='from->to'.", Example: rewrite-db='from->to'.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"skip-annotate-rows-events", OPT_SKIP_ANNOTATE_ROWS_EVENTS,
"Don't print Annotate_rows events stored in the binary log.",
(uchar**) &opt_skip_annotate_rows_events,
(uchar**) &opt_skip_annotate_rows_events,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -1683,6 +1791,8 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, ...@@ -1683,6 +1791,8 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
cast to uint32. cast to uint32.
*/ */
int4store(buf, (uint32)start_position); int4store(buf, (uint32)start_position);
if (!opt_skip_annotate_rows_events)
binlog_flags|= BINLOG_SEND_ANNOTATE_ROWS_EVENT;
int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
size_t tlen = strlen(logname); size_t tlen = strlen(logname);
...@@ -1715,18 +1825,30 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, ...@@ -1715,18 +1825,30 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
break; // end of data break; // end of data
DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n", DBUG_PRINT("info",( "len: %lu net->read_pos[5]: %d\n",
len, net->read_pos[5])); len, net->read_pos[5]));
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 , if (net->read_pos[5] == ANNOTATE_ROWS_EVENT)
len - 1, &error_msg,
glob_description_event)))
{ {
error("Could not construct log event object: %s", error_msg); if (!(ev= read_remote_annotate_event(net->read_pos + 1, len - 1,
DBUG_RETURN(ERROR_STOP); &error_msg)))
} {
/* error("Could not construct annotate event object: %s", error_msg);
If reading from a remote host, ensure the temp_buf for the DBUG_RETURN(ERROR_STOP);
Log_event class is pointing to the incoming stream. }
*/ }
ev->register_temp_buf((char *) net->read_pos + 1, FALSE); else
{
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
len - 1, &error_msg,
glob_description_event)))
{
error("Could not construct log event object: %s", error_msg);
DBUG_RETURN(ERROR_STOP);
}
/*
If reading from a remote host, ensure the temp_buf for the
Log_event class is pointing to the incoming stream.
*/
ev->register_temp_buf((char *) net->read_pos + 1, FALSE);
}
Log_event_type type= ev->get_type_code(); Log_event_type type= ev->get_type_code();
if (glob_description_event->binlog_version >= 3 || if (glob_description_event->binlog_version >= 3 ||
...@@ -2236,6 +2358,7 @@ int main(int argc, char** argv) ...@@ -2236,6 +2358,7 @@ int main(int argc, char** argv)
if (result_file != stdout) if (result_file != stdout)
my_fclose(result_file, MYF(0)); my_fclose(result_file, MYF(0));
cleanup(); cleanup();
free_annotate_event();
delete binlog_filter; delete binlog_filter;
free_root(&s_mem_root, MYF(0)); free_root(&s_mem_root, MYF(0));
free_defaults(defaults_argv); free_defaults(defaults_argv);
......
...@@ -77,6 +77,9 @@ ...@@ -77,6 +77,9 @@
#define IGNORE_DATA 0x01 /* don't dump data for this table */ #define IGNORE_DATA 0x01 /* don't dump data for this table */
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */ #define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
/* Chars needed to store LONGLONG, excluding trailing '\0'. */
#define LONGLONG_LEN 20
static void add_load_option(DYNAMIC_STRING *str, const char *option, static void add_load_option(DYNAMIC_STRING *str, const char *option,
const char *option_value); const char *option_value);
static ulong find_set(TYPELIB *lib, const char *x, uint length, static ulong find_set(TYPELIB *lib, const char *x, uint length,
...@@ -344,9 +347,9 @@ static struct my_option my_long_options[] = ...@@ -344,9 +347,9 @@ static struct my_option my_long_options[] =
"This causes the binary log position and filename to be appended to the " "This causes the binary log position and filename to be appended to the "
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal" "output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
" to 2, that command will be prefixed with a comment symbol. " " to 2, that command will be prefixed with a comment symbol. "
"This option will turn --lock-all-tables on, unless " "This option will turn --lock-all-tables on, unless --single-transaction "
"--single-transaction is specified too (in which case a " "is specified too (on servers before MariaDB 5.3 this will still take a "
"global read lock is only taken a short time at the beginning of the dump; " "global read lock for a short time at the beginning of the dump; "
"don't forget to read about --single-transaction below). In all cases, " "don't forget to read about --single-transaction below). In all cases, "
"any action on logs will happen at the exact moment of the dump. " "any action on logs will happen at the exact moment of the dump. "
"Option automatically turns --lock-tables off.", "Option automatically turns --lock-tables off.",
...@@ -1110,6 +1113,44 @@ static int fetch_db_collation(const char *db_name, ...@@ -1110,6 +1113,44 @@ static int fetch_db_collation(const char *db_name,
} }
/*
Check if server supports non-blocking binlog position using the
binlog_snapshot_file and binlog_snapshot_position status variables. If it
does, also return the position obtained if output pointers are non-NULL.
Returns 1 if position available, 0 if not.
*/
static int
check_consistent_binlog_pos(char *binlog_pos_file, char *binlog_pos_offset)
{
MYSQL_RES *res;
MYSQL_ROW row;
int found;
if (mysql_query_with_error_report(mysql, &res,
"SHOW STATUS LIKE 'binlog_snapshot_%'"))
return 1;
found= 0;
while ((row= mysql_fetch_row(res)))
{
if (0 == strcmp(row[0], "binlog_snapshot_file"))
{
if (binlog_pos_file)
strmake(binlog_pos_file, row[1], FN_REFLEN-1);
found++;
}
else if (0 == strcmp(row[0], "binlog_snapshot_position"))
{
if (binlog_pos_offset)
strmake(binlog_pos_offset, row[1], LONGLONG_LEN);
found++;
}
}
mysql_free_result(res);
return (found == 2);
}
static char *my_case_str(const char *str, static char *my_case_str(const char *str,
uint str_len, uint str_len,
const char *token, const char *token,
...@@ -4352,42 +4393,65 @@ static int dump_selected_tables(char *db, char **table_names, int tables) ...@@ -4352,42 +4393,65 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
} /* dump_selected_tables */ } /* dump_selected_tables */
static int do_show_master_status(MYSQL *mysql_con) static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos)
{ {
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_RES *master; MYSQL_RES *master;
char binlog_pos_file[FN_REFLEN];
char binlog_pos_offset[LONGLONG_LEN+1];
char *file, *offset;
const char *comment_prefix= const char *comment_prefix=
(opt_master_data == MYSQL_OPT_MASTER_DATA_COMMENTED_SQL) ? "-- " : ""; (opt_master_data == MYSQL_OPT_MASTER_DATA_COMMENTED_SQL) ? "-- " : "";
if (mysql_query_with_error_report(mysql_con, &master, "SHOW MASTER STATUS"))
if (consistent_binlog_pos)
{ {
return 1; if(!check_consistent_binlog_pos(binlog_pos_file, binlog_pos_offset))
return 1;
file= binlog_pos_file;
offset= binlog_pos_offset;
} }
else else
{ {
if (mysql_query_with_error_report(mysql_con, &master, "SHOW MASTER STATUS"))
return 1;
row= mysql_fetch_row(master); row= mysql_fetch_row(master);
if (row && row[0] && row[1]) if (row && row[0] && row[1])
{ {
/* SHOW MASTER STATUS reports file and position */ file= row[0];
if (opt_comments) offset= row[1];
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
comment_prefix, row[0], row[1]);
check_io(md_result_file);
} }
else if (!ignore_errors) else
{ {
/* SHOW MASTER STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Binlogging on server not active",
MYF(0));
mysql_free_result(master); mysql_free_result(master);
maybe_exit(EX_MYSQLERR); if (!ignore_errors)
return 1; {
/* SHOW MASTER STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Binlogging on server not active",
MYF(0));
maybe_exit(EX_MYSQLERR);
return 1;
}
else
{
return 0;
}
} }
mysql_free_result(master);
} }
/* SHOW MASTER STATUS reports file and position */
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from\n--\n\n");
fprintf(md_result_file,
"%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
comment_prefix, file, offset);
check_io(md_result_file);
if (!consistent_binlog_pos)
mysql_free_result(master);
return 0; return 0;
} }
...@@ -5026,6 +5090,7 @@ int main(int argc, char **argv) ...@@ -5026,6 +5090,7 @@ int main(int argc, char **argv)
{ {
char bin_log_name[FN_REFLEN]; char bin_log_name[FN_REFLEN];
int exit_code; int exit_code;
int consistent_binlog_pos= 0;
MY_INIT("mysqldump"); MY_INIT("mysqldump");
compatible_mode_normal_str[0]= 0; compatible_mode_normal_str[0]= 0;
...@@ -5056,7 +5121,13 @@ int main(int argc, char **argv) ...@@ -5056,7 +5121,13 @@ int main(int argc, char **argv)
if (!path) if (!path)
write_header(md_result_file, *argv); write_header(md_result_file, *argv);
if ((opt_lock_all_tables || opt_master_data) && if (opt_single_transaction && opt_master_data)
{
/* See if we can avoid FLUSH TABLES WITH READ LOCK (MariaDB 5.3+). */
consistent_binlog_pos= check_consistent_binlog_pos(NULL, NULL);
}
if ((opt_lock_all_tables || (opt_master_data && !consistent_binlog_pos)) &&
do_flush_tables_read_lock(mysql)) do_flush_tables_read_lock(mysql))
goto err; goto err;
if (opt_single_transaction && start_transaction(mysql)) if (opt_single_transaction && start_transaction(mysql))
...@@ -5074,7 +5145,7 @@ int main(int argc, char **argv) ...@@ -5074,7 +5145,7 @@ int main(int argc, char **argv)
goto err; goto err;
flush_logs= 0; /* not anymore; that would not be sensible */ flush_logs= 0; /* not anymore; that would not be sensible */
} }
if (opt_master_data && do_show_master_status(mysql)) if (opt_master_data && do_show_master_status(mysql, consistent_binlog_pos))
goto err; goto err;
if (opt_single_transaction && do_unlock_tables(mysql)) /* unlock but no commit! */ if (opt_single_transaction && do_unlock_tables(mysql)) /* unlock but no commit! */
goto err; goto err;
......
...@@ -561,6 +561,8 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); ...@@ -561,6 +561,8 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
#define my_b_tell(info) ((info)->pos_in_file + \ #define my_b_tell(info) ((info)->pos_in_file + \
(size_t) (*(info)->current_pos - (info)->request_pos)) (size_t) (*(info)->current_pos - (info)->request_pos))
#define my_b_write_tell(info) ((info)->pos_in_file + \
((info)->write_pos - (info)->write_buffer))
#define my_b_get_buffer_start(info) (info)->request_pos #define my_b_get_buffer_start(info) (info)->request_pos
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \ #define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
......
...@@ -321,14 +321,19 @@ let $MYSQLD_DATADIR= `select @@datadir`; ...@@ -321,14 +321,19 @@ let $MYSQLD_DATADIR= `select @@datadir`;
# we check that the error code of the "ROLLBACK" event is 0 and not # we check that the error code of the "ROLLBACK" event is 0 and not
# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
# and does not make slave to stop) # and does not make slave to stop)
-- source include/binlog_start_pos.inc
if (`select @@binlog_format = 'ROW'`) if (`select @@binlog_format = 'ROW'`)
{ {
--exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output let $start_pos= `select @binlog_start_pos + 418`;
--exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
} }
if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
{ {
--exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output let $start_pos= `select @binlog_start_pos + 449`;
--exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
} }
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
......
...@@ -72,7 +72,7 @@ connection slave; ...@@ -72,7 +72,7 @@ connection slave;
--source include/stop_slave.inc --source include/stop_slave.inc
DELETE FROM t2; DELETE FROM t2;
# Set slave position to the BEGIN log event # Set slave position to the BEGIN log event
--replace_result $master_pos_begin MASTER_POS_BEGIN --replace_result $master_pos_begin <master_pos_begin>
eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin; eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
BEGIN; BEGIN;
# Hold lock # Hold lock
...@@ -103,7 +103,7 @@ SET global max_relay_log_size=0; ...@@ -103,7 +103,7 @@ SET global max_relay_log_size=0;
--source include/stop_slave.inc --source include/stop_slave.inc
DELETE FROM t2; DELETE FROM t2;
# Set slave position to the BEGIN log event # Set slave position to the BEGIN log event
--replace_result $master_pos_begin MASTER_POS_BEGIN --replace_result $master_pos_begin <master_pos_begin>
eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin; eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
BEGIN; BEGIN;
# Hold lock # Hold lock
......
...@@ -14,6 +14,7 @@ source include/stop_slave.inc; ...@@ -14,6 +14,7 @@ source include/stop_slave.inc;
reset master; reset master;
reset slave; reset slave;
source include/start_slave.inc; source include/start_slave.inc;
source include/binlog_start_pos.inc;
let $VERSION=`select version()`; let $VERSION=`select version()`;
......
########################################################################
# WL47: Store in binlog text of statements that caused RBR events
# new event : ANNOTATE_ROWS_EVENT
# new master option : --binlog-annotate-rows-events
# new slave option : --replicate-annotate-rows-events
########################################################################
--source include/master-slave.inc
connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
connection master;
--disable_query_log
--disable_warnings
DROP DATABASE IF EXISTS test1;
--enable_warnings
CREATE DATABASE test1;
USE test1;
CREATE TABLE t1(a int primary key, b int);
CREATE TABLE t2(a int, b int);
CREATE TABLE t3(a int, b int);
CREATE TABLE t4(a int, b int);
CREATE TABLE xt1(a int, b int);
CREATE TABLE xt2(a int, b int);
CREATE TABLE t5 (
a INT PRIMARY KEY AUTO_INCREMENT,
b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
);
SET SESSION binlog_annotate_rows_events = OFF;
INSERT INTO t1 VALUES (0,0), (1,1);
SET SESSION binlog_annotate_rows_events = ON;
UPDATE t1 SET b = b + 1;
REPLACE t1 VALUES (1,1), (2,2), (3,3);
INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
INSERT INTO t3 VALUES (1,1), (2,2), (3,3);
DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a;
INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a;
INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
INSERT INTO xt2 VALUES (1,1), (2,2), (3,3);
DELETE xt1, xt2 FROM xt1 INNER JOIN xt2 INNER JOIN t3 WHERE xt1.a=xt2.a AND xt2.a=t3.a;
INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz');
SET NAMES latin1;
INSERT INTO t5(b) VALUES ('gs');
SET NAMES utf8;
INSERT INTO t5(b) VALUES ('gås');
SET NAMES latin1;
FLUSH LOGS;
--echo ########################################################################
--echo # TABLES ON MASTER
--echo ########################################################################
--enable_query_log
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT * FROM t3 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
sync_slave_with_master;
--echo ########################################################################
--echo # TABLES ON SLAVE: should be the same as on master
--echo ########################################################################
--disable_query_log
USE test1;
--enable_query_log
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT * FROM t3 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
--echo ########################################################################
--echo # EVENTS ON SLAVE
let $annotate= `select @@global.replicate_annotate_rows_events`;
if ($annotate)
{
--echo # The following Annotate_rows events should appear below:
--echo # - UPDATE t1 SET b = b + 1;
--echo # - REPLACE t1 VALUES (1,1), (2,2), (3,3);
--echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
--echo # - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
--echo # - DELETE t1, t2 FROM <...>
--echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
--echo # - DELETE xt1, t2 FROM <...>
--echo # - INSERT INTO t5(b) VALUES <...> (3 instances)
}
if (!$annotate)
{
--echo # No Annotate_rows events should appear below
}
--echo ########################################################################
FLUSH LOGS;
--source include/binlog_start_pos.inc
let $start_pos= `select @binlog_start_pos`;
--replace_column 2 # 5 #
--replace_result $start_pos <start_pos>
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
--eval show binlog events in 'slave-bin.000001' from $start_pos
--echo #
--echo ########################################################################
--echo # INSERTs DELAYED ON MASTERs
--echo ########################################################################
connection master;
SET SESSION binlog_annotate_rows_events = ON;
INSERT DELAYED INTO test1.t4 VALUES (1,1);
FLUSH TABLES;
SELECT * FROM test1.t4 ORDER BY a;
sync_slave_with_master;
connection master;
sync_slave_with_master;
--echo ########################################################################
--echo # ON SLAVE
--echo # No Annotate_rows events should appear below
--echo ########################################################################
FLUSH LOGS;
--exec $MYSQL --host=127.0.0.1 --port=$SLAVE_MYPORT test -e "show binlog events in 'slave-bin.000002'" > $MYSQLTEST_VARDIR/tmp/annotated_events.txt
perl;
open F, '<', "$ENV{MYSQLTEST_VARDIR}/tmp/annotated_events.txt" or die;
binmode STDOUT;
while (defined ($_ = <F>)) {
if (/Annotate_rows/) {
s/[0-9]+\sAnnotate_rows\s[0-9]+\s[0-9]+/# Annotate_rows # #/;
print($_);
$_ = <F>;
s/[0-9]+\sTable_map\s[0-9]+\s[0-9]+\stable_id:\s[0-9]+/# Table_map # # table_id: #/;
print($_);
}
}
EOF
# Clean-up
connection master;
--disable_query_log
DROP DATABASE test1;
sync_slave_with_master;
--enable_query_log
--source include/rpl_end.inc
##############################################################################
#
# binlog_start_pos is the postion of the the first event in the binary log
# which follows the Format description event. Intended to reduce test suite
# dependance on the Format description event length changes (e.g. in case
# of adding new events). Evaluated as:
#
# binlog_start_pos = 4 /* binlog header */ +
# (Format_description_log_event length)
#
# Format_description_log_event length =
# 19 /* event common header */ +
# 57 /* misc stuff in the Format description header */ +
# number of events.
#
# With current number of events = 160,
#
# binlog_start_pos = 4 + 19 + 57 + 160 = 240.
#
##############################################################################
let $binlog_start_pos=240;
--disable_query_log
SET @binlog_start_pos=240;
--enable_query_log
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# #
# Useage: # Useage:
# let $binlog_file= master-bin.000002; # let $binlog_file= master-bin.000002;
# let $binlog_start= 106; # let $binlog_start= 240;
# let $binlog_limit= 1, 3; # let $binlog_limit= 1, 3;
# source include/show_binlog_events.inc; # source include/show_binlog_events.inc;
# #
......
--let $binlog_start=106 --let $binlog_start=240
--replace_result $binlog_start <binlog_start> --replace_result $binlog_start <binlog_start>
--replace_column 2 # 5 # --replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
......
...@@ -44,8 +44,6 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t4 VALUES ( NAME_CONST('in ...@@ -44,8 +44,6 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t4 VALUES ( NAME_CONST('in
master-bin.000001 # Query # # use `test`; DROP PROCEDURE bug18293 master-bin.000001 # Query # # use `test`; DROP PROCEDURE bug18293
master-bin.000001 # Query # # use `test`; DROP TABLE t4 master-bin.000001 # Query # # use `test`; DROP TABLE t4
End of 5.0 tests End of 5.0 tests
SHOW BINLOG EVENTS FROM 365;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932; CREATE TABLE t1 (a varchar(16)) character set cp932;
INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
......
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (k INT NOT NULL, a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, PRIMARY KEY(k)) ENGINE=InnoDB;
INSERT INTO t1 (k, a, b, c) VALUES (1, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (2, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (3, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (4, 0, 0, 0);
RESET MASTER;
SET DEBUG_SYNC= 'RESET';
# Connection c1
SET binlog_format= mixed;
BEGIN;
UPDATE t1 SET a=10 WHERE k=1;
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committing";
COMMIT;
# Connection c2
SET binlog_format= mixed;
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
BEGIN;
SELECT * FROM t1 WHERE k=1 FOR UPDATE;
k a b c
1 10 0 0
UPDATE t1 SET a=20 WHERE k=1;
SET DEBUG_SYNC="now SIGNAL c2_committing";
COMMIT;
# Connection c1
BEGIN;
UPDATE t1 SET a=10 WHERE k=2;
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committed TIMEOUT 2";
COMMIT;
# Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
BEGIN;
SELECT * FROM t1 WHERE k=2 FOR UPDATE;
k a b c
2 10 0 0
UPDATE t1 SET a=20 WHERE k=2;
SET DEBUG_SYNC="binlog_after_log_and_order SIGNAL c2_committed";
COMMIT;
# Connection c1
# This should warn about DEBUG_SYNC timeout
Warnings:
Warning 1639 debug sync point wait timed out
# Connection c2
SHOW BINLOG EVENTS LIMIT 2,12;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=10 WHERE k=1
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=20 WHERE k=1
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=10 WHERE k=2
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=20 WHERE k=2
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
# Connection c1
RESET MASTER;
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committing";
UPDATE t1 SET a=10 WHERE k=3;
# Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
SELECT * FROM t1 WHERE k=3 FOR UPDATE;
k a b c
3 10 0 0
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c2_committing";
UPDATE t1 SET a=20 WHERE k=3;
# Connection c1
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committed TIMEOUT 2";
UPDATE t1 SET a=10 WHERE k=4;
# Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
SELECT * FROM t1 WHERE k=4 FOR UPDATE;
k a b c
4 10 0 0
SET DEBUG_SYNC="binlog_after_log_and_order SIGNAL c2_committed";
UPDATE t1 SET a=20 WHERE k=4;
# Connection c1
# This should warn about DEBUG_SYNC timeout
Warnings:
Warning 1639 debug sync point wait timed out
# Connection c2
SHOW BINLOG EVENTS LIMIT 1,12;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=10 WHERE k=3
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=20 WHERE k=3
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=10 WHERE k=4
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; UPDATE t1 SET a=20 WHERE k=4
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
SELECT * FROM t1 ORDER BY k;
k a b c
1 20 0 0
2 20 0 0
3 20 0 0
4 20 0 0
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
reset master; reset master;
SET @save_binlog_size= @@global.max_binlog_size;
SET @@global.max_binlog_size= 4096;
set timestamp=1000000000; set timestamp=1000000000;
drop table if exists t1,t2,t3,t4,t5,t03,t04; drop table if exists t1,t2,t3,t4,t5,t03,t04;
create table t1 (word varchar(20)); create table t1 (word varchar(20));
create table t2 (id int auto_increment not null primary key); create table t2 (id int auto_increment not null primary key);
insert into t1 values ("abirvalg"); insert into t1 values ("abirvalg");
insert into t2 values (); insert into t2 values ();
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words3.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words3.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words3.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words3.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words3.dat' into table t1;
insert into t1 values ("Alas"); insert into t1 values ("Alas");
flush logs; flush logs;
...@@ -220,7 +222,6 @@ ROLLBACK /* added by mysqlbinlog */; ...@@ -220,7 +222,6 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/; DELIMITER /*!*/;
ROLLBACK/*!*/; ROLLBACK/*!*/;
use test/*!*/;
SET TIMESTAMP=1108844556/*!*/; SET TIMESTAMP=1108844556/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
...@@ -228,6 +229,7 @@ SET @@session.lc_time_names=0/*!*/; ...@@ -228,6 +229,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/; SET @@session.collation_database=DEFAULT/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
use test/*!*/;
SET TIMESTAMP=1108844555/*!*/; SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1) insert t1 values (1)
/*!*/; /*!*/;
...@@ -239,7 +241,6 @@ Warning: The option '--position' is deprecated and will be removed in a future r ...@@ -239,7 +241,6 @@ Warning: The option '--position' is deprecated and will be removed in a future r
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/; DELIMITER /*!*/;
use test/*!*/;
SET TIMESTAMP=1108844556/*!*/; SET TIMESTAMP=1108844556/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
...@@ -247,6 +248,7 @@ SET @@session.lc_time_names=0/*!*/; ...@@ -247,6 +248,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/; SET @@session.collation_database=DEFAULT/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
use test/*!*/;
SET TIMESTAMP=1108844555/*!*/; SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1) insert t1 values (1)
/*!*/; /*!*/;
...@@ -255,6 +257,7 @@ DELIMITER ; ...@@ -255,6 +257,7 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */; ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
drop table t1,t2; drop table t1,t2;
SET @@global.max_binlog_size= @save_binlog_size;
flush logs; flush logs;
flush logs; flush logs;
select * from t5 /* must be (1),(1) */; select * from t5 /* must be (1),(1) */;
...@@ -377,14 +380,14 @@ LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FI ...@@ -377,14 +380,14 @@ LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FI
/*!*/; /*!*/;
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/; SET @@session.collation_database=7/*!*/;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`) LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
/*!*/; /*!*/;
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/; SET @@session.collation_database=DEFAULT/*!*/;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`) LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
/*!*/; /*!*/;
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`) LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
/*!*/; /*!*/;
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
drop table t1 drop table t1
...@@ -581,7 +584,6 @@ SET @@session.lc_time_names=0/*!*/; ...@@ -581,7 +584,6 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/; SET @@session.collation_database=DEFAULT/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
use test/*!*/;
SET TIMESTAMP=1266652094/*!*/; SET TIMESTAMP=1266652094/*!*/;
SavePoint mixed_cases SavePoint mixed_cases
/*!*/; /*!*/;
...@@ -592,11 +594,9 @@ INSERT INTO db1.t2 VALUES("in savepoint mixed_cases") ...@@ -592,11 +594,9 @@ INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
SET TIMESTAMP=1266652094/*!*/; SET TIMESTAMP=1266652094/*!*/;
INSERT INTO db1.t1 VALUES(40) INSERT INTO db1.t1 VALUES(40)
/*!*/; /*!*/;
use test/*!*/;
SET TIMESTAMP=1266652094/*!*/; SET TIMESTAMP=1266652094/*!*/;
ROLLBACK TO mixed_cases ROLLBACK TO mixed_cases
/*!*/; /*!*/;
use db1/*!*/;
SET TIMESTAMP=1266652094/*!*/; SET TIMESTAMP=1266652094/*!*/;
INSERT INTO db1.t2 VALUES("after rollback to") INSERT INTO db1.t2 VALUES("after rollback to")
/*!*/; /*!*/;
...@@ -624,7 +624,6 @@ SET @@session.lc_time_names=0/*!*/; ...@@ -624,7 +624,6 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/; SET @@session.collation_database=DEFAULT/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
use test/*!*/;
SET TIMESTAMP=1266652094/*!*/; SET TIMESTAMP=1266652094/*!*/;
SavePoint mixed_cases SavePoint mixed_cases
/*!*/; /*!*/;
......
...@@ -290,3 +290,60 @@ COUNT(*) ...@@ -290,3 +290,60 @@ COUNT(*)
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL storage_engine=@old_engine; SET GLOBAL storage_engine=@old_engine;
# Connection default
SET binlog_format= mixed;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,0), (2,0);
SELECT GET_LOCK("block_queries_1", 120);
GET_LOCK("block_queries_1", 120)
1
# Connection c3
SELECT GET_LOCK("block_queries_2", 120);
GET_LOCK("block_queries_2", 120)
1
# Connection c1
SET @c= 0;
SELECT IF(@c<1, @c:=@c+1, GET_LOCK("block_queries_1", 120)) FROM t1 ORDER BY a;
# Connection c2
SET binlog_format="row";
SET @d= 10;
UPDATE t2 SET b=IF(@d<=10, @d:=@d+1, GET_LOCK("block_queries_2", 120)) ORDER BY a;
# Connection default
# Make sure other queries are running (and waiting).
SELECT RELEASE_LOCK("block_queries_1");
RELEASE_LOCK("block_queries_1")
1
# Connection c3
SELECT RELEASE_LOCK("block_queries_2");
RELEASE_LOCK("block_queries_2")
1
# Connection c1
IF(@c<1, @c:=@c+1, GET_LOCK("block_queries_1", 120))
1
1
# Connection c2
# Connection default
SELECT * FROM t2 ORDER BY a;
a b
1 11
2 1
DROP TABLE t1;
DROP TABLE t2;
SHOW BINLOG EVENTS LIMIT 6,3;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 658 Query 1 726 BEGIN
master-bin.000001 726 Query 1 823 use `test`; INSERT INTO t2 VALUES (1,0), (2,0)
master-bin.000001 823 Xid 1 850 COMMIT /* XID */
-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=850;
SELECT * FROM t1 ORDER BY a;
a
1
2
SELECT * FROM t2 ORDER BY a;
a b
1 0
2 0
DROP TABLE t1,t2;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET binlog_format= mixed;
RESET MASTER;
XA START 'xatest';
INSERT INTO t1 VALUES (1);
XA END 'xatest';
XA PREPARE 'xatest';
XA COMMIT 'xatest';
XA START 'xatest';
INSERT INTO t1 VALUES (2);
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
BEGIN;
INSERT INTO t1 VALUES (3);
COMMIT;
SELECT * FROM t1 ORDER BY a;
a
1
2
3
SHOW BINLOG EVENTS LIMIT 1,9;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (3)
master-bin.000001 # Xid 1 # COMMIT /* xid=XX */
DROP TABLE t1;
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
abandoning
abandonment
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
CALL mtr.add_suppression("Error writing file 'master-bin'");
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES(0);
SET SESSION debug='+d,fail_binlog_write_1';
INSERT INTO t1 VALUES(1);
ERROR HY000: Error writing file 'master-bin' (errno: 28)
INSERT INTO t1 VALUES(2);
ERROR HY000: Error writing file 'master-bin' (errno: 28)
SET SESSION debug='';
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
a
0
3
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
BINLOG POS Format_desc 1 ENDPOS Server ver: #, Binlog ver: #
BINLOG POS Query 1 ENDPOS use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb
BINLOG POS Query 1 ENDPOS BEGIN
BINLOG POS Query 1 ENDPOS use `test`; INSERT INTO t1 VALUES(0)
BINLOG POS Xid 1 ENDPOS COMMIT /* XID */
BINLOG POS Query 1 ENDPOS BEGIN
BINLOG POS Query 1 ENDPOS BEGIN
BINLOG POS Query 1 ENDPOS BEGIN
BINLOG POS Query 1 ENDPOS use `test`; INSERT INTO t1 VALUES(3)
BINLOG POS Xid 1 ENDPOS COMMIT /* XID */
DROP TABLE t1;
This diff is collapsed.
...@@ -333,7 +333,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values( 244 ) ...@@ -333,7 +333,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values( 244 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 243 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 243 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 242 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 242 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 241 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 241 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 240 ) master-bin.000001 # Query # # use `test`; insert into t1 values( <binlog_start> )
master-bin.000001 # Query # # use `test`; insert into t1 values( 239 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 239 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 238 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 238 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 237 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 237 )
...@@ -467,7 +467,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values( 110 ) ...@@ -467,7 +467,7 @@ master-bin.000001 # Query # # use `test`; insert into t1 values( 110 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 109 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 109 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 108 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 108 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 107 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 107 )
master-bin.000001 # Query # # use `test`; insert into t1 values( <binlog_start> ) master-bin.000001 # Query # # use `test`; insert into t1 values( 106 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 105 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 105 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 104 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 104 )
master-bin.000001 # Query # # use `test`; insert into t1 values( 103 ) master-bin.000001 # Query # # use `test`; insert into t1 values( 103 )
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
source include/have_log_bin.inc; source include/have_log_bin.inc;
source include/have_debug.inc; source include/have_debug.inc;
source include/binlog_start_pos.inc;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
RESET MASTER; RESET MASTER;
...@@ -20,7 +21,7 @@ REPLACE INTO t1 VALUES (4); ...@@ -20,7 +21,7 @@ REPLACE INTO t1 VALUES (4);
DROP TABLE t1; DROP TABLE t1;
FLUSH LOGS; FLUSH LOGS;
exec $MYSQL_BINLOG --start-position=106 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql; exec $MYSQL_BINLOG --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
--disable_query_log --disable_query_log
eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl; eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
--enable_query_log --enable_query_log
......
source include/have_debug.inc;
source include/have_innodb.inc;
source include/have_log_bin.inc;
source include/have_binlog_format_mixed_or_statement.inc;
CALL mtr.add_suppression("Error writing file 'master-bin'");
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES(0);
SET SESSION debug='+d,fail_binlog_write_1';
--error ER_ERROR_ON_WRITE
INSERT INTO t1 VALUES(1);
--error ER_ERROR_ON_WRITE
INSERT INTO t1 VALUES(2);
SET SESSION debug='';
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
# Actually the output from this currently shows a bug.
# The injected IO error leaves partially written transactions in the binlog in
# the form of stray "BEGIN" events.
# These should disappear from the output if binlog error handling is improved
# (see MySQL Bug#37148 and WL#1790).
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
--replace_column 1 BINLOG 2 POS 5 ENDPOS
SHOW BINLOG EVENTS;
DROP TABLE t1;
-- source include/have_innodb.inc -- source include/have_innodb.inc
-- source include/have_binlog_format_statement.inc -- source include/have_binlog_format_statement.inc
-- source include/binlog_start_pos.inc
# You cannot use `KILL' with the Embedded MySQL Server library, # You cannot use `KILL' with the Embedded MySQL Server library,
# because the embedded server merely runs inside the threads of the host # because the embedded server merely runs inside the threads of the host
...@@ -51,7 +52,8 @@ reap; ...@@ -51,7 +52,8 @@ reap;
let $rows= `select count(*) from t2 /* must be 2 or 0 */`; let $rows= `select count(*) from t2 /* must be 2 or 0 */`;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --force-if-open --start-position=134 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog let $start_pos= `select @binlog_start_pos + 28`;
--exec $MYSQL_BINLOG --force-if-open --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) (@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
......
-- source include/have_debug.inc -- source include/have_debug.inc
-- source include/have_binlog_format_statement.inc -- source include/have_binlog_format_statement.inc
-- source include/binlog_start_pos.inc
# #
# bug#27571 asynchronous setting mysql_$query()'s local error and # bug#27571 asynchronous setting mysql_$query()'s local error and
# Query_log_event::error_code # Query_log_event::error_code
...@@ -24,7 +25,7 @@ update t1 set a=2 /* will be "killed" after work has been done */; ...@@ -24,7 +25,7 @@ update t1 set a=2 /* will be "killed" after work has been done */;
# for some constants like the offset of the first real event # for some constants like the offset of the first real event
# that is different between severs versions. # that is different between severs versions.
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog --exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
......
--timezone=GMT-3 --binlog-do-db=test1 --binlog-do-db=test2 --binlog-do-db=test3
###############################################################################
# WL47: Store in binlog text of statements that caused RBR events
# new event: ANNOTATE_ROWS_EVENT
# new master option: --binlog-annotate-rows-events
# new mysqlbinlog option: --skip-annotate-rows-events
#
# Intended to test that:
# *** If the --binlog-annotate-rows-events option is switched on on master
# then Annotate_rows events:
# - are generated;
# - are genrated only once for "multi-table-maps" rbr queries;
# - are not generated when the corresponding queries are filtered away;
# - are generated when the corresponding queries are filtered away partialy
# (e.g. in case of multi-delete).
# *** Annotate_rows events are printed by mysqlbinlog started without
# --skip-annotate-rows-events options both in remote and local cases.
# *** Annotate_rows events are not printed by mysqlbinlog started with
# --skip-annotate-rows-events options both in remote and local cases.
###############################################################################
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
--source include/binlog_start_pos.inc
--disable_query_log
# Fix timestamp to avoid varying results
SET timestamp=1000000000;
# Delete all existing binary logs
RESET MASTER;
--disable_warnings
DROP DATABASE IF EXISTS test1;
DROP DATABASE IF EXISTS test2;
DROP DATABASE IF EXISTS test3;
DROP DATABASE IF EXISTS xtest1;
DROP DATABASE IF EXISTS xtest2;
--enable_warnings
CREATE DATABASE test1;
CREATE TABLE test1.t1(a int);
CREATE DATABASE test2;
CREATE TABLE test2.t2(a int);
CREATE VIEW test2.v2 AS SELECT * FROM test2.t2;
CREATE DATABASE test3;
CREATE TABLE test3.t3(a int);
CREATE DATABASE xtest1;
CREATE TABLE xtest1.xt1(a int);
CREATE DATABASE xtest2;
CREATE TABLE xtest2.xt2(a int);
# By default SESSION binlog_annotate_rows_events = OFF
INSERT INTO test1.t1 VALUES (1), (2), (3);
SET SESSION binlog_annotate_rows_events = ON;
INSERT INTO test2.t2 VALUES (1), (2), (3);
INSERT INTO test3.t3 VALUES (1), (2), (3);
# This query generates two Table maps but the Annotate
# event should appear only once before the first Table map
DELETE test1.t1, test2.t2
FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
# This event should be filtered out together with Annotate event
INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
# This event should pass the filter
INSERT INTO test2.v2 VALUES (1), (2), (3);
# This event should pass the filter only for test2.t2 part
DELETE xtest1.xt1, test2.t2
FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
# These events should be filtered out together with Annotate events
INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
INSERT INTO xtest2.xt2 VALUES (1), (2), (3);
DELETE xtest1.xt1, xtest2.xt2
FROM xtest1.xt1 INNER JOIN xtest2.xt2 INNER JOIN test3.t3
WHERE xtest1.xt1.a=xtest2.xt2.a AND xtest2.xt2.a=test3.t3.a;
FLUSH LOGS;
--enable_query_log
--echo #####################################################################################
--echo # The following Annotate_rows events should appear below:
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
--echo # - DELETE test1.t1, test2.t2 FROM <...>
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...>
--echo #####################################################################################
let $start_pos= `select @binlog_start_pos`;
--replace_column 2 # 5 #
--replace_result $start_pos <start_pos>
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
--eval show binlog events in 'master-bin.000001' from $start_pos
--echo #
--echo #####################################################################################
--echo # mysqlbinlog
--echo # The following Annotates should appear in this output:
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
--echo #
--echo #####################################################################################
--echo # mysqlbinlog --database=test1
--echo # The following Annotate should appear in this output:
--echo # - DELETE test1.t1, test2.t2 FROM <...>
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v $MYSQLD_DATADIR/master-bin.000001
--echo #
--echo #####################################################################################
--echo # mysqlbinlog --skip-annotate-rows-events
--echo # No Annotates should appear in this output
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v $MYSQLD_DATADIR/master-bin.000001
--echo #
--echo #####################################################################################
--echo # mysqlbinlog --read-from-remote-server
--echo # The following Annotates should appear in this output:
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
--echo #
--echo #####################################################################################
--echo # mysqlbinlog --read-from-remote-server --database=test1
--echo # The following Annotate should appear in this output:
--echo # - DELETE test1.t1, test2.t2 FROM <...>
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
--echo #
--echo #####################################################################################
--echo # mysqlbinlog --read-from-remote-server --skip-annotate-rows-events
--echo # No Annotates should appear in this output
--echo #####################################################################################
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
# Clean-up
--disable_query_log
DROP DATABASE test1;
DROP DATABASE test2;
DROP DATABASE test3;
DROP DATABASE xtest1;
DROP DATABASE xtest2;
--enable_query_log
RESET MASTER;
# Connection default
CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb;
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 375
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 375
BEGIN;
INSERT INTO t1 VALUES (0, "");
# Connection con1
BEGIN;
INSERT INTO t1 VALUES (1, "");
# Connection con2
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam;
BEGIN;
INSERT INTO t1 VALUES (2, "first");
INSERT INTO t2 VALUES (2);
INSERT INTO t1 VALUES (2, "second");
# Connection default
COMMIT;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
# Connection con3
BEGIN;
INSERT INTO t1 VALUES (3, "");
INSERT INTO t2 VALUES (3);
# Connection con4
BEGIN;
INSERT INTO t1 VALUES (4, "");
COMMIT;
# Connection default
SELECT * FROM t1 ORDER BY a,b;
a b
0
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 674
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 861
SELECT * FROM t2 ORDER BY a;
a
2
3
# Connection con1
COMMIT;
# Connection con2
COMMIT;
# Connection con3
COMMIT;
FLUSH LOGS;
# Connection default
SELECT * FROM t1 ORDER BY a,b;
a b
0
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 674
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000002 240
COMMIT;
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file master-bin.000002
binlog_snapshot_position 240
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000002 240
SHOW BINLOG EVENTS;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 4 Format_desc 1 240 Server ver: #, Binlog ver: #
master-bin.000001 240 Query 1 375 use `test`; CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb
master-bin.000001 375 Query 1 487 use `test`; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam
master-bin.000001 487 Query 1 555 BEGIN
master-bin.000001 555 Query 1 647 use `test`; INSERT INTO t1 VALUES (0, "")
master-bin.000001 647 Xid 1 674 COMMIT /* XID */
master-bin.000001 674 Query 1 742 BEGIN
master-bin.000001 742 Query 1 834 use `test`; INSERT INTO t1 VALUES (4, "")
master-bin.000001 834 Xid 1 861 COMMIT /* XID */
master-bin.000001 861 Query 1 929 BEGIN
master-bin.000001 929 Query 1 1021 use `test`; INSERT INTO t1 VALUES (1, "")
master-bin.000001 1021 Xid 1 1048 COMMIT /* XID */
master-bin.000001 1048 Query 1 1116 BEGIN
master-bin.000001 1116 Query 1 1213 use `test`; INSERT INTO t1 VALUES (2, "first")
master-bin.000001 1213 Query 1 1301 use `test`; INSERT INTO t2 VALUES (2)
master-bin.000001 1301 Query 1 1399 use `test`; INSERT INTO t1 VALUES (2, "second")
master-bin.000001 1399 Xid 1 1426 COMMIT /* XID */
master-bin.000001 1426 Query 1 1494 BEGIN
master-bin.000001 1494 Query 1 1586 use `test`; INSERT INTO t1 VALUES (3, "")
master-bin.000001 1586 Query 1 1674 use `test`; INSERT INTO t2 VALUES (3)
master-bin.000001 1674 Xid 1 1701 COMMIT /* XID */
master-bin.000001 1701 Rotate 1 1745 master-bin.000002;pos=4
DROP TABLE t1,t2;
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb;
SELECT variable_value INTO @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value INTO @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group1_running WAIT_FOR group2_queued";
INSERT INTO t1 VALUES ("con1");
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
SET DEBUG_SYNC= "commit_after_group_run_commit_ordered SIGNAL group2_visible WAIT_FOR group2_checked";
INSERT INTO t1 VALUES ("con2");
SET DEBUG_SYNC= "now WAIT_FOR group2_con2";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con3";
INSERT INTO t1 VALUES ("con3");
SET DEBUG_SYNC= "now WAIT_FOR group2_con3";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con4";
INSERT INTO t1 VALUES ("con4");
SET DEBUG_SYNC= "now WAIT_FOR group2_con4";
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM t1 ORDER BY a;
a
SET DEBUG_SYNC= "now SIGNAL group2_queued";
SELECT * FROM t1 ORDER BY a;
a
con1
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
INSERT INTO t1 VALUES ("con5");
SET DEBUG_SYNC= "now WAIT_FOR con5_leader";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con6_queued";
INSERT INTO t1 VALUES ("con6");
SET DEBUG_SYNC= "now WAIT_FOR group3_con5";
SELECT * FROM t1 ORDER BY a;
a
con1
SET DEBUG_SYNC= "now SIGNAL group3_committed";
SET DEBUG_SYNC= "now WAIT_FOR group2_visible";
SELECT * FROM t1 ORDER BY a;
a
con1
con2
con3
con4
SET DEBUG_SYNC= "now SIGNAL group2_checked";
SELECT * FROM t1 ORDER BY a;
a
con1
con2
con3
con4
con5
con6
SELECT variable_value - @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
variable_value - @commits
6
SELECT variable_value - @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
variable_value - @group_commits
3
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES (0);
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con1_waiting WAIT_FOR con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont EXECUTE 3";
INSERT INTO t1 VALUES (1);
SET DEBUG_SYNC= "now WAIT_FOR con1_waiting";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con2_queued";
INSERT INTO t1 VALUES (2);
SET DEBUG_SYNC= "now WAIT_FOR con2_queued";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued";
INSERT INTO t1 VALUES (3);
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SELECT * FROM t1 ORDER BY a;
a
0
1
2
SET SESSION debug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
SELECT * FROM t1 ORDER BY a;
a
0
1
2
3
InnoDB: Last MySQL binlog file position 0 901, file name ./master-bin.000001
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES (0);
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con1_waiting WAIT_FOR con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
INSERT INTO t1 VALUES (1);
SET DEBUG_SYNC= "now WAIT_FOR con1_waiting";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con2_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
INSERT INTO t1 VALUES (2);
SET DEBUG_SYNC= "now WAIT_FOR con2_queued";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
INSERT INTO t1 VALUES (3);
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
SELECT * FROM t1 ORDER BY a;
a
0
1
2
SET SESSION debug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
Got one of the listed errors
SELECT * FROM t1 ORDER BY a;
a
0
1
2
3
InnoDB: Last MySQL binlog file position 0 901, file name ./master-bin.000001
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
FLUSH TABLES;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(5);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(4);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(3);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(2);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(1);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
FLUSH TABLES;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(5);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(4);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(3);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(2);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2
delete from t1;
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(1);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb;
SELECT variable_value INTO @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value INTO @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group1_running WAIT_FOR group2_queued";
INSERT INTO t1 VALUES ("con1");
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
INSERT INTO t1 VALUES ("con2");
SET DEBUG_SYNC= "now WAIT_FOR group2_con2";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con3";
INSERT INTO t1 VALUES ("con3");
SET DEBUG_SYNC= "now WAIT_FOR group2_con3";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con4";
SET DEBUG_SYNC= "commit_after_group_run_commit_ordered SIGNAL group2_visible WAIT_FOR group2_checked";
INSERT INTO t1 VALUES ("con4");
SET DEBUG_SYNC= "now WAIT_FOR group2_con4";
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM t1 ORDER BY a;
a
SET DEBUG_SYNC= "now SIGNAL group2_queued";
SELECT * FROM t1 ORDER BY a;
a
con1
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
INSERT INTO t1 VALUES ("con5");
SET DEBUG_SYNC= "now WAIT_FOR con5_leader";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con6_queued";
INSERT INTO t1 VALUES ("con6");
SET DEBUG_SYNC= "now WAIT_FOR group3_con5";
SELECT * FROM t1 ORDER BY a;
a
con1
SET DEBUG_SYNC= "now SIGNAL group3_committed";
SET DEBUG_SYNC= "now WAIT_FOR group2_visible";
SELECT * FROM t1 ORDER BY a;
a
con1
con2
con3
con4
SET DEBUG_SYNC= "now SIGNAL group2_checked";
SELECT * FROM t1 ORDER BY a;
a
con1
con2
con3
con4
con5
con6
SELECT variable_value - @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
variable_value - @commits
6
SELECT variable_value - @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
variable_value - @group_commits
3
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
--source include/have_log_bin.inc
--source include/have_binlog_format_mixed_or_statement.inc
--source include/have_innodb_plugin.inc
RESET MASTER;
# Test that we get the correct binlog position from START TRANSACTION WITH
# CONSISTENT SNAPSHOT even when other transactions are active.
connect(con1,localhost,root,,);
connect(con2,localhost,root,,);
connect(con3,localhost,root,,);
connect(con4,localhost,root,,);
connection default;
--echo # Connection default
CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb;
SHOW MASTER STATUS;
SHOW STATUS LIKE 'binlog_snapshot_%';
BEGIN;
INSERT INTO t1 VALUES (0, "");
connection con1;
--echo # Connection con1
BEGIN;
INSERT INTO t1 VALUES (1, "");
connection con2;
--echo # Connection con2
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam;
BEGIN;
INSERT INTO t1 VALUES (2, "first");
INSERT INTO t2 VALUES (2);
INSERT INTO t1 VALUES (2, "second");
connection default;
--echo # Connection default
COMMIT;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection con3;
--echo # Connection con3
BEGIN;
INSERT INTO t1 VALUES (3, "");
INSERT INTO t2 VALUES (3);
connection con4;
--echo # Connection con4
BEGIN;
INSERT INTO t1 VALUES (4, "");
COMMIT;
connection default;
--echo # Connection default
SELECT * FROM t1 ORDER BY a,b;
SHOW STATUS LIKE 'binlog_snapshot_%';
SHOW MASTER STATUS;
SELECT * FROM t2 ORDER BY a;
connection con1;
--echo # Connection con1
COMMIT;
connection con2;
--echo # Connection con2
COMMIT;
connection con3;
--echo # Connection con3
COMMIT;
FLUSH LOGS;
connection default;
--echo # Connection default
SELECT * FROM t1 ORDER BY a,b;
SHOW STATUS LIKE 'binlog_snapshot_%';
SHOW MASTER STATUS;
COMMIT;
SHOW STATUS LIKE 'binlog_snapshot_%';
SHOW MASTER STATUS;
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS;
DROP TABLE t1,t2;
--source include/have_debug_sync.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
# Test some group commit code paths by using debug_sync to do controlled
# commits of 6 transactions: first 1 alone, then 3 as a group, then 2 as a
# group.
#
# Group 3 is allowed to race as far as possible ahead before group 2 finishes
# to check some edge case for concurrency control.
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb;
SELECT variable_value INTO @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value INTO @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
connect(con1,localhost,root,,);
connect(con2,localhost,root,,);
connect(con3,localhost,root,,);
connect(con4,localhost,root,,);
connect(con5,localhost,root,,);
connect(con6,localhost,root,,);
# Start group1 (with one thread) doing commit, waiting for
# group2 to queue up before finishing.
connection con1;
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group1_running WAIT_FOR group2_queued";
send INSERT INTO t1 VALUES ("con1");
# Make group2 (with three threads) queue up.
# Make sure con2 is the group commit leader for group2.
# Make group2 wait with running commit_ordered() until group3 has committed.
connection con2;
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
SET DEBUG_SYNC= "commit_after_group_run_commit_ordered SIGNAL group2_visible WAIT_FOR group2_checked";
send INSERT INTO t1 VALUES ("con2");
connection con3;
SET DEBUG_SYNC= "now WAIT_FOR group2_con2";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con3";
send INSERT INTO t1 VALUES ("con3");
connection con4;
SET DEBUG_SYNC= "now WAIT_FOR group2_con3";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con4";
send INSERT INTO t1 VALUES ("con4");
# When group2 is queued, let group1 continue and queue group3.
connection default;
SET DEBUG_SYNC= "now WAIT_FOR group2_con4";
# At this point, trasaction 1 is still not visible as commit_ordered() has not
# been called yet.
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group2_queued";
connection con1;
reap;
# Now transaction 1 is visible.
connection default;
SELECT * FROM t1 ORDER BY a;
connection con5;
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
send INSERT INTO t1 VALUES ("con5");
connection con6;
SET DEBUG_SYNC= "now WAIT_FOR con5_leader";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con6_queued";
send INSERT INTO t1 VALUES ("con6");
connection default;
SET DEBUG_SYNC= "now WAIT_FOR group3_con5";
# Still only transaction 1 visible, as group2 have not yet run commit_ordered().
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group3_committed";
SET DEBUG_SYNC= "now WAIT_FOR group2_visible";
# Now transactions 1-4 visible.
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group2_checked";
connection con2;
reap;
connection con3;
reap;
connection con4;
reap;
connection con5;
reap;
connection con6;
reap;
connection default;
# Check all transactions finally visible.
SELECT * FROM t1 ORDER BY a;
SELECT variable_value - @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value - @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
--source include/have_debug_sync.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
--source include/have_binlog_format_mixed_or_statement.inc
# Need DBUG to crash the server intentionally
--source include/have_debug.inc
# Don't test this under valgrind, memory leaks will occur as we crash
--source include/not_valgrind.inc
# The test case currently uses grep and tail, which may be unavailable on
# some windows systems. But see MWL#191 for how to remove the need for grep.
--source include/not_windows.inc
# XtraDB stores the binlog position corresponding to the last commit, and
# prints it during crash recovery.
# Test that we get the correct position when we group commit several
# transactions together.
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES (0);
connect(con1,localhost,root,,);
connect(con2,localhost,root,,);
connect(con3,localhost,root,,);
# Queue up three commits for group commit.
connection con1;
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con1_waiting WAIT_FOR con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont EXECUTE 3";
send INSERT INTO t1 VALUES (1);
connection con2;
SET DEBUG_SYNC= "now WAIT_FOR con1_waiting";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con2_queued";
send INSERT INTO t1 VALUES (2);
connection con3;
SET DEBUG_SYNC= "now WAIT_FOR con2_queued";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued";
send INSERT INTO t1 VALUES (3);
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, no transactions are committed.
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, 1 transaction is committed.
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, 2 transactions are committed.
SELECT * FROM t1 ORDER BY a;
connection con2;
reap;
# Now crash the server with 1+2 in-memory committed, 3 only prepared.
connection default;
system echo wait-group_commit_binlog_pos.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
SET SESSION debug="+d,crash_dispatch_command_before";
--error 2006,2013
SELECT 1;
connection con1;
--error 2006,2013
reap;
connection con3;
--error 2006,2013
reap;
system echo restart-group_commit_binlog_pos.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
connection default;
--enable_reconnect
--source include/wait_until_connected_again.inc
# Crash recovery should recover all three transactions.
SELECT * FROM t1 ORDER BY a;
# Check that the binlog position reported by InnoDB is the correct one
# for the end of the second transaction (as can be checked with
# mysqlbinlog).
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--exec grep 'InnoDB: Last MySQL binlog file position' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
--binlog-optimize-thread-scheduling=0 --skip-stack-trace --skip-core-file
--source include/have_debug_sync.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
--source include/have_binlog_format_mixed_or_statement.inc
# Need DBUG to crash the server intentionally
--source include/have_debug.inc
# Don't test this under valgrind, memory leaks will occur as we crash
--source include/not_valgrind.inc
# The test case currently uses grep and tail, which may be unavailable on
# some windows systems. But see MWL#191 for how to remove the need for grep.
--source include/not_windows.inc
# XtraDB stores the binlog position corresponding to the last commit, and
# prints it during crash recovery.
# Test that we get the correct position when we group commit several
# transactions together.
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES (0);
connect(con1,localhost,root,,);
connect(con2,localhost,root,,);
connect(con3,localhost,root,,);
# Queue up three commits for group commit.
connection con1;
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con1_waiting WAIT_FOR con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
send INSERT INTO t1 VALUES (1);
connection con2;
SET DEBUG_SYNC= "now WAIT_FOR con1_waiting";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con2_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
send INSERT INTO t1 VALUES (2);
connection con3;
SET DEBUG_SYNC= "now WAIT_FOR con2_queued";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued";
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont";
send INSERT INTO t1 VALUES (3);
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, no transactions are committed.
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, 1 transaction is committed.
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
# At this point, 2 transactions are committed.
SELECT * FROM t1 ORDER BY a;
connection con1;
reap;
connection con2;
reap;
# Now crash the server with 1+2 in-memory committed, 3 only prepared.
connection default;
system echo wait-group_commit_binlog_pos_no_optimize_thread.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
SET SESSION debug="+d,crash_dispatch_command_before";
--error 2006,2013
SELECT 1;
connection con3;
--error 2006,2013
reap;
system echo restart-group_commit_binlog_pos_no_optimize_thread.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
connection default;
--enable_reconnect
--source include/wait_until_connected_again.inc
# Crash recovery should recover all three transactions.
SELECT * FROM t1 ORDER BY a;
# Check that the binlog position reported by InnoDB is the correct one
# for the end of the second transaction (as can be checked with
# mysqlbinlog).
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--exec grep 'InnoDB: Last MySQL binlog file position' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
# Testing group commit by crashing a few times.
# Test adapted from the Facebook patch: lp:mysqlatfacebook
--source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
let $file_format_check=`SELECT @@innodb_file_format_check`;
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
delimiter //;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
delimiter ;//
# Avoid getting a crashed mysql.proc table.
FLUSH TABLES;
let $numtests = 5;
let $numinserts = 10;
while ($numinserts)
{
dec $numinserts;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
}
--enable_reconnect
while ($numtests)
{
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
# Write file to make mysql-test-run.pl expect crash
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
eval call setcrash($numtests);
# Run the crashing query
--error 2006,2013
COMMIT;
# Poll the server waiting for it to be back online again.
--source include/wait_until_connected_again.inc
# table and binlog should be in sync.
SELECT * FROM t1 ORDER BY id;
--replace_column 2 # 5 #
SHOW BINLOG EVENTS LIMIT 2,1;
delete from t1;
dec $numtests;
}
# final cleanup
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
--disable_query_log
eval SET GLOBAL innodb_file_format_check=$file_format_check;
--enable_query_log
--binlog-optimize-thread-scheduling=0 --skip-stack-trace --skip-core-file
# Testing group commit by crashing a few times.
# Test adapted from the Facebook patch: lp:mysqlatfacebook
--source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
let $file_format_check=`SELECT @@innodb_file_format_check`;
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
delimiter //;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
delimiter ;//
# Avoid getting a crashed mysql.proc table.
FLUSH TABLES;
let $numtests = 5;
let $numinserts = 10;
while ($numinserts)
{
dec $numinserts;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
}
--enable_reconnect
while ($numtests)
{
SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
# Write file to make mysql-test-run.pl expect crash
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
eval call setcrash($numtests);
# Run the crashing query
--error 2006,2013
COMMIT;
# Poll the server waiting for it to be back online again.
--source include/wait_until_connected_again.inc
# table and binlog should be in sync.
SELECT * FROM t1 ORDER BY id;
--replace_column 2 # 5 #
SHOW BINLOG EVENTS LIMIT 2,1;
delete from t1;
dec $numtests;
}
# final cleanup
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
--disable_query_log
eval SET GLOBAL innodb_file_format_check=$file_format_check;
--enable_query_log
--source include/have_debug_sync.inc
--source include/have_innodb_plugin.inc
--source include/have_log_bin.inc
# Test some group commit code paths by using debug_sync to do controlled
# commits of 6 transactions: first 1 alone, then 3 as a group, then 2 as a
# group.
#
# Group 3 is allowed to race as far as possible ahead before group 2 finishes
# to check some edge case for concurrency control.
CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb;
SELECT variable_value INTO @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value INTO @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
connect(con1,localhost,root,,);
connect(con2,localhost,root,,);
connect(con3,localhost,root,,);
connect(con4,localhost,root,,);
connect(con5,localhost,root,,);
connect(con6,localhost,root,,);
# Start group1 (with one thread) doing commit, waiting for
# group2 to queue up before finishing.
connection con1;
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group1_running WAIT_FOR group2_queued";
send INSERT INTO t1 VALUES ("con1");
# Make group2 (with three threads) queue up.
# Make sure con2 is the group commit leader for group2.
# Make group2 wait with running commit_ordered() until group3 has committed.
connection con2;
set DEBUG_SYNC= "now WAIT_FOR group1_running";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con2";
SET DEBUG_SYNC= "commit_after_release_LOCK_log WAIT_FOR group3_committed";
send INSERT INTO t1 VALUES ("con2");
connection con3;
SET DEBUG_SYNC= "now WAIT_FOR group2_con2";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con3";
send INSERT INTO t1 VALUES ("con3");
connection con4;
SET DEBUG_SYNC= "now WAIT_FOR group2_con3";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL group2_con4";
SET DEBUG_SYNC= "commit_after_group_run_commit_ordered SIGNAL group2_visible WAIT_FOR group2_checked";
send INSERT INTO t1 VALUES ("con4");
# When group2 is queued, let group1 continue and queue group3.
connection default;
SET DEBUG_SYNC= "now WAIT_FOR group2_con4";
# At this point, trasaction 1 is still not visible as commit_ordered() has not
# been called yet.
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group2_queued";
connection con1;
reap;
# Now transaction 1 is visible.
connection default;
SELECT * FROM t1 ORDER BY a;
connection con5;
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL group3_con5";
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con5_leader WAIT_FOR con6_queued";
send INSERT INTO t1 VALUES ("con5");
connection con6;
SET DEBUG_SYNC= "now WAIT_FOR con5_leader";
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con6_queued";
send INSERT INTO t1 VALUES ("con6");
connection default;
SET DEBUG_SYNC= "now WAIT_FOR group3_con5";
# Still only transaction 1 visible, as group2 have not yet run commit_ordered().
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group3_committed";
SET DEBUG_SYNC= "now WAIT_FOR group2_visible";
# Now transactions 1-4 visible.
SELECT * FROM t1 ORDER BY a;
SET DEBUG_SYNC= "now SIGNAL group2_checked";
connection con2;
reap;
connection con3;
reap;
connection con4;
reap;
connection con5;
reap;
connection con6;
reap;
connection default;
# Check all transactions finally visible.
SELECT * FROM t1 ORDER BY a;
SELECT variable_value - @commits FROM information_schema.global_status
WHERE variable_name = 'binlog_commits';
SELECT variable_value - @group_commits FROM information_schema.global_status
WHERE variable_name = 'binlog_group_commits';
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
...@@ -14,10 +14,10 @@ a ...@@ -14,10 +14,10 @@ a
2 2
3 3
4 4
SHOW BINLOG EVENTS FROM 106; SHOW BINLOG EVENTS FROM <start_pos>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 106 Query 1 204 use `test`; CREATE TABLE t1 (a int primary key) master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1 (a int primary key)
master-bin.000001 204 Query 1 295 use `test`; insert t1 values (1),(2),(3) master-bin.000001 # Query 1 # use `test`; insert t1 values (1),(2),(3)
master-bin.000001 295 Query 1 386 use `test`; insert t1 values (4),(2),(5) master-bin.000001 # Query 1 # use `test`; insert t1 values (4),(2),(5)
drop table t1; drop table t1;
set binlog_format=default; set binlog_format=default;
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
-- source include/have_maria.inc -- source include/have_maria.inc
-- source include/have_log_bin.inc -- source include/have_log_bin.inc
-- source include/binlog_start_pos.inc
let $start_pos= `select @binlog_start_pos`;
let $default=`select @@global.storage_engine`; let $default=`select @@global.storage_engine`;
set global storage_engine=aria; set global storage_engine=aria;
...@@ -27,7 +30,9 @@ insert t1 values (1),(2),(3); ...@@ -27,7 +30,9 @@ insert t1 values (1),(2),(3);
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
insert t1 values (4),(2),(5); insert t1 values (4),(2),(5);
select * from t1; select * from t1;
SHOW BINLOG EVENTS FROM 106; --replace_result $start_pos <start_pos>
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS FROM $start_pos;
drop table t1; drop table t1;
set binlog_format=default; set binlog_format=default;
......
drop table if exists t1, t2;
SET binlog_format = 'mixed';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt;
BEGIN;
SELECT @@log_bin;
@@log_bin
1
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
COMMIT;
select * from t1;
a
1
select * from t2;
b
2
SET sql_log_bin = 0;
BEGIN;
INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4);
COMMIT;
select * from t1 order by a;
a
1
3
select * from t2 order by b;
b
2
4
drop table t1, t2;
drop database pbxt;
--source include/have_innodb.inc
--source include/have_log_bin.inc
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
SET binlog_format = 'mixed';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt;
BEGIN;
# verify that binlog is on
SELECT @@log_bin;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
COMMIT;
select * from t1;
select * from t2;
# Test 2-phase commit when we disable binlogging.
SET sql_log_bin = 0;
BEGIN;
INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4);
COMMIT;
select * from t1 order by a;
select * from t2 order by b;
drop table t1, t2;
drop database pbxt;
...@@ -51,7 +51,7 @@ include/check_slave_is_running.inc ...@@ -51,7 +51,7 @@ include/check_slave_is_running.inc
*** Test lock wait timeout *** *** Test lock wait timeout ***
include/stop_slave.inc include/stop_slave.inc
DELETE FROM t2; DELETE FROM t2;
CHANGE MASTER TO MASTER_LOG_POS=MASTER_POS_BEGIN; CHANGE MASTER TO MASTER_LOG_POS=<master_pos_begin>;
BEGIN; BEGIN;
SELECT * FROM t1 FOR UPDATE; SELECT * FROM t1 FOR UPDATE;
a a
...@@ -78,7 +78,7 @@ SET @my_max_relay_log_size= @@global.max_relay_log_size; ...@@ -78,7 +78,7 @@ SET @my_max_relay_log_size= @@global.max_relay_log_size;
SET global max_relay_log_size=0; SET global max_relay_log_size=0;
include/stop_slave.inc include/stop_slave.inc
DELETE FROM t2; DELETE FROM t2;
CHANGE MASTER TO MASTER_LOG_POS=MASTER_POS_BEGIN; CHANGE MASTER TO MASTER_LOG_POS=<master_pos_begin>;
BEGIN; BEGIN;
SELECT * FROM t1 FOR UPDATE; SELECT * FROM t1 FOR UPDATE;
a a
......
include/master-slave.inc
[connection master]
########################################################################
# TABLES ON MASTER
########################################################################
SELECT * FROM t1 ORDER BY a;
a b
0 1
SELECT * FROM t2 ORDER BY a;
a b
SELECT * FROM t3 ORDER BY a;
a b
1 1
2 2
3 3
SELECT * FROM t5 ORDER BY a;
a b
1 foo
2 bar
3 baz
4 gs
5 gs
########################################################################
# TABLES ON SLAVE: should be the same as on master
########################################################################
SELECT * FROM t1 ORDER BY a;
a b
0 1
SELECT * FROM t2 ORDER BY a;
a b
SELECT * FROM t3 ORDER BY a;
a b
1 1
2 2
3 3
SELECT * FROM t5 ORDER BY a;
a b
1 foo
2 bar
3 baz
4 gs
5 gs
########################################################################
# EVENTS ON SLAVE
# The following Annotate_rows events should appear below:
# - UPDATE t1 SET b = b + 1;
# - REPLACE t1 VALUES (1,1), (2,2), (3,3);
# - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
# - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
# - DELETE t1, t2 FROM <...>
# - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
# - DELETE xt1, t2 FROM <...>
# - INSERT INTO t5(b) VALUES <...> (3 instances)
########################################################################
FLUSH LOGS;
show binlog events in 'slave-bin.000001' from <start_pos>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query 1 # DROP DATABASE IF EXISTS test1
slave-bin.000001 # Query 1 # CREATE DATABASE test1
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t1(a int primary key, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t2(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t3(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t4(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t5 (
a INT PRIMARY KEY AUTO_INCREMENT,
b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
)
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # UPDATE t1 SET b = b + 1
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Update_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # REPLACE t1 VALUES (1,1), (2,2), (3,3)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Update_rows 1 # table_id: #
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t3)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Delete_rows 1 # table_id: #
slave-bin.000001 # Delete_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Delete_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz')
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t5(b) VALUES ('gs')
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Annotate_rows 1 # INSERT INTO t5(b) VALUES ('gås')
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
#
########################################################################
# INSERTs DELAYED ON MASTERs
########################################################################
SET SESSION binlog_annotate_rows_events = ON;
INSERT DELAYED INTO test1.t4 VALUES (1,1);
FLUSH TABLES;
SELECT * FROM test1.t4 ORDER BY a;
a b
1 1
########################################################################
# ON SLAVE
# No Annotate_rows events should appear below
########################################################################
FLUSH LOGS;
include/rpl_end.inc
include/master-slave.inc
[connection master]
########################################################################
# TABLES ON MASTER
########################################################################
SELECT * FROM t1 ORDER BY a;
a b
0 1
SELECT * FROM t2 ORDER BY a;
a b
SELECT * FROM t3 ORDER BY a;
a b
1 1
2 2
3 3
SELECT * FROM t5 ORDER BY a;
a b
1 foo
2 bar
3 baz
4 gs
5 gs
########################################################################
# TABLES ON SLAVE: should be the same as on master
########################################################################
SELECT * FROM t1 ORDER BY a;
a b
0 1
SELECT * FROM t2 ORDER BY a;
a b
SELECT * FROM t3 ORDER BY a;
a b
1 1
2 2
3 3
SELECT * FROM t5 ORDER BY a;
a b
1 foo
2 bar
3 baz
4 gs
5 gs
########################################################################
# EVENTS ON SLAVE
# No Annotate_rows events should appear below
########################################################################
FLUSH LOGS;
show binlog events in 'slave-bin.000001' from <start_pos>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query 1 # DROP DATABASE IF EXISTS test1
slave-bin.000001 # Query 1 # CREATE DATABASE test1
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t1(a int primary key, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t2(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t3(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t4(a int, b int)
slave-bin.000001 # Query 1 # use `test1`; CREATE TABLE t5 (
a INT PRIMARY KEY AUTO_INCREMENT,
b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
)
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Update_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Update_rows 1 # table_id: #
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t3)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Table_map 1 # table_id: # (test1.t1)
slave-bin.000001 # Delete_rows 1 # table_id: #
slave-bin.000001 # Delete_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t2)
slave-bin.000001 # Delete_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Query 1 # BEGIN
slave-bin.000001 # Table_map 1 # table_id: # (test1.t5)
slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
slave-bin.000001 # Query 1 # COMMIT
slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
#
########################################################################
# INSERTs DELAYED ON MASTERs
########################################################################
SET SESSION binlog_annotate_rows_events = ON;
INSERT DELAYED INTO test1.t4 VALUES (1,1);
FLUSH TABLES;
SELECT * FROM test1.t4 ORDER BY a;
a b
1 1
########################################################################
# ON SLAVE
# No Annotate_rows events should appear below
########################################################################
FLUSH LOGS;
include/rpl_end.inc
...@@ -22,7 +22,7 @@ a ...@@ -22,7 +22,7 @@ a
[on slave] [on slave]
---- Wait until slave stops with an error ---- ---- Wait until slave stops with an error ----
include/wait_for_slave_sql_error.inc [errno=1062] include/wait_for_slave_sql_error.inc [errno=1062]
Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 346 (expected "duplicate key" error) Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 480 (expected "duplicate key" error)
SELECT * FROM t1; SELECT * FROM t1;
a a
1 1
......
include/master-slave.inc
[connection master]
CREATE TABLE t1 (a int, b varchar(100), fulltext(b)) engine=MyISAM;
INSERT INTO t1 VALUES (1,"a"), (2,"b");
UPDATE t1 SET b='A' WHERE a=1;
DELETE FROM t1 WHERE a=2;
SELECT * FROM t1 ORDER BY a;
a b
1 A
DROP TABLE t1;
CREATE TABLE t1 (d INT PRIMARY KEY) ENGINE=myisam;
INSERT INTO t1 VALUES (0);
INSERT INTO t1 SELECT d+1 FROM t1;
INSERT INTO t1 SELECT d+2 FROM t1;
INSERT INTO t1 SELECT d+4 FROM t1;
INSERT INTO t1 SELECT d+8 FROM t1;
INSERT INTO t1 SELECT d+16 FROM t1;
INSERT INTO t1 SELECT d+32 FROM t1;
INSERT INTO t1 SELECT d+64 FROM t1;
INSERT INTO t1 SELECT d+128 FROM t1;
INSERT INTO t1 SELECT d+256 FROM t1;
INSERT INTO t1 SELECT d+512 FROM t1;
CREATE TABLE t2 (a INT, b INT, c INT, d INT,
KEY wrong_key(a),
KEY expected_key(b,c),
KEY wrong_key2(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d
4 1 5 10042
DROP TABLE t2;
CREATE TABLE t2 (a INT, b INT, c INT, d INT NOT NULL, e INT,
UNIQUE wrong_key3(a,e),
KEY wrong_key4(b,c),
UNIQUE expected_key(d)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, NULL FROM t1;
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d e
4 1 5 10042 NULL
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
KEY wrong_key5(b),
UNIQUE expected_key(d),
KEY wrong_key6(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d
4 1 5 10042
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
KEY expected_key(b),
KEY wrong_key7(d),
KEY wrong_key8(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d
4 1 5 10042
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT,
UNIQUE wrong_key9(d),
KEY wrong_key10(a),
PRIMARY KEY expected_key(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan,slave_crash_if_index_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d
4 1 5 10042
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
UNIQUE wrong_key11(e),
KEY wrong_key12(a),
KEY expected_key(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d e
4 1 5 10042 NULL
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
KEY wrong_key13(a),
UNIQUE expected_key(e),
KEY wrong_key14(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
# Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
a b c d e
4 1 5 10042 NULL
DROP TABLE t2;
CREATE TABLE t2 (a INT NOT NULL, d INT) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d FROM t1;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
SELECT * FROM t2 WHERE d IN (10042,53);
a d
4 10042
DROP TABLE t2;
DROP TABLE t1;
SET GLOBAL debug="";
include/rpl_end.inc
--log-slave-updates --replicate-annotate-rows-events --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
\ No newline at end of file
###############################################################################
# WL47: Store in binlog text of statements that caused RBR events
# Wrapper for extra/rpl/rpl_row_annotate.test.
# Intended to test that if the --replicate-annotate-rows-events option
# is switched on on slave then Annotate_events:
# - are reproduced on slave
# - are reproduced only once for "multi-table-maps" rbr queries
# - are not reproduced when the corresponding queries are filtered away
# on replication
# - are reproduced when the corresponding queries are filtered away partialy
# (e.g. in case of multi-delete)
# - are not generated on slave for queries that are not annotated on master.
###############################################################################
--source include/have_binlog_format_row.inc
--source extra/rpl_tests/rpl_row_annotate.test
--log-slave-updates --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
\ No newline at end of file
###############################################################################
# WL47: Store in binlog text of statements that caused RBR events
# Wrapper for extra/rpl/rpl_row_annotate.test.
# Intended to test that if the --replicate-annotate-rows-events option
# is switched off on slave then Annotate_events are not reproduced.
###############################################################################
--source include/have_binlog_format_row.inc
--source extra/rpl_tests/rpl_row_annotate.test
# depends on the binlog output # depends on the binlog output
-- source include/have_binlog_format_row.inc -- source include/have_binlog_format_row.inc
--source include/binlog_start_pos.inc
let $rename_event_pos= 925; let $rename_event_pos= `select @binlog_start_pos + 819`;
# Bug#18326: Do not lock table for writing during prepare of statement # Bug#18326: Do not lock table for writing during prepare of statement
# The use of the ps protocol causes extra table maps in the binlog, so # The use of the ps protocol causes extra table maps in the binlog, so
......
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--source include/have_debug.inc
--source include/have_innodb.inc
# Bug#58997: Row-based replication breaks on table with only fulltext index:
connection master;
CREATE TABLE t1 (a int, b varchar(100), fulltext(b)) engine=MyISAM;
INSERT INTO t1 VALUES (1,"a"), (2,"b");
UPDATE t1 SET b='A' WHERE a=1;
DELETE FROM t1 WHERE a=2;
sync_slave_with_master;
connection slave;
SELECT * FROM t1 ORDER BY a;
connection master;
DROP TABLE t1;
# A utility table used to populate subsequent tables in various ways.
connection master;
CREATE TABLE t1 (d INT PRIMARY KEY) ENGINE=myisam;
INSERT INTO t1 VALUES (0);
INSERT INTO t1 SELECT d+1 FROM t1;
INSERT INTO t1 SELECT d+2 FROM t1;
INSERT INTO t1 SELECT d+4 FROM t1;
INSERT INTO t1 SELECT d+8 FROM t1;
INSERT INTO t1 SELECT d+16 FROM t1;
INSERT INTO t1 SELECT d+32 FROM t1;
INSERT INTO t1 SELECT d+64 FROM t1;
INSERT INTO t1 SELECT d+128 FROM t1;
INSERT INTO t1 SELECT d+256 FROM t1;
INSERT INTO t1 SELECT d+512 FROM t1;
# Test that we pick the better multi-column index, even if the
# single-column index is more selective in the first column.
CREATE TABLE t2 (a INT, b INT, c INT, d INT,
KEY wrong_key(a),
KEY expected_key(b,c),
KEY wrong_key2(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
sync_slave_with_master;
connection slave;
ANALYZE TABLE t2;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
# Test that we don't pick a unique index with NULLS over a more selective
# non-unique index.
connection master;
DROP TABLE t2;
CREATE TABLE t2 (a INT, b INT, c INT, d INT NOT NULL, e INT,
UNIQUE wrong_key3(a,e),
KEY wrong_key4(b,c),
UNIQUE expected_key(d)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, NULL FROM t1;
sync_slave_with_master;
connection slave;
ANALYZE TABLE t2;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# Test that we pick a reasonable index when there is no rec_per_key[]
# information (no ANALYZE TABLE).
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
KEY wrong_key5(b),
UNIQUE expected_key(d),
KEY wrong_key6(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
sync_slave_with_master;
connection slave;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# Also test without ANALYZE when we pick the sub-optimal index.
# In this case the key on (d) is the best one, but without ANALYZE TABLE we
# have no information and will pick the first one on (b).
# (This test should be updated if we improve the index selection, of course).
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
KEY expected_key(b),
KEY wrong_key7(d),
KEY wrong_key8(c)) ENGINE=myisam;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
sync_slave_with_master;
connection slave;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# Test that we pick the primary key for InnoDB, if available.
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT,
UNIQUE wrong_key9(d),
KEY wrong_key10(a),
PRIMARY KEY expected_key(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
sync_slave_with_master;
connection slave;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan,slave_crash_if_index_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# Test that we pick a good index for InnoDB when primary key is not available.
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
UNIQUE wrong_key11(e),
KEY wrong_key12(a),
KEY expected_key(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
sync_slave_with_master;
connection slave;
ANALYZE TABLE t2;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# When there is no ANALYZE TABLE, InnoDB will just report "1" for index
# cardinality for all indexes in rec_per_key. So currently we cannot choose
# index to use intelligently. Just test that we work as expected (select
# first index, remember that unique keys are sorted first by server).
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
KEY wrong_key13(a),
UNIQUE expected_key(e),
KEY wrong_key14(c,b)) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
sync_slave_with_master;
connection slave;
--echo # Slave will crash if using the wrong or no index
SET GLOBAL debug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
connection master;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
# Finally, test behaviour when no indexes are available at all.
CREATE TABLE t2 (a INT NOT NULL, d INT) ENGINE=innodb;
INSERT INTO t2 SELECT d DIV 10, d FROM t1;
UPDATE t2 SET d=10042 WHERE d=42;
DELETE FROM t2 WHERE d=53;
sync_slave_with_master;
connection slave;
SELECT * FROM t2 WHERE d IN (10042,53);
connection master;
DROP TABLE t2;
connection master;
DROP TABLE t1;
sync_slave_with_master;
connection slave;
SET GLOBAL debug="";
--source include/rpl_end.inc
...@@ -164,15 +164,18 @@ connection master; ...@@ -164,15 +164,18 @@ connection master;
remove_file $MYSQLTEST_VARDIR/tmp/master.sql; remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
--source include/binlog_start_pos.inc
# this test for position option # this test for position option
# By setting this position to 416, we should only get the create of t3 # By setting this position to start_binlog_pos + 310, we should only get the create of t3
let $start_pos= `select @binlog_start_pos + 310`;
let $stop_pos= `select @binlog_start_pos + 463`;
--disable_query_log --disable_query_log
select "--- Test 2 position test --" as ""; select "--- Test 2 position test --" as "";
--enable_query_log --enable_query_log
let $MYSQLD_DATADIR= `select @@datadir;`; let $MYSQLD_DATADIR= `select @@datadir;`;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 --stop-position=569 $MYSQLD_DATADIR/master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=$start_pos --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
# These are tests for remote binlog. # These are tests for remote binlog.
# They should return the same as previous test. # They should return the same as previous test.
...@@ -183,7 +186,7 @@ select "--- Test 3 First Remote test --" as ""; ...@@ -183,7 +186,7 @@ select "--- Test 3 First Remote test --" as "";
# This is broken now # This is broken now
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=569 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
# This part is disabled due to bug #17654 # This part is disabled due to bug #17654
...@@ -259,7 +262,7 @@ connection master; ...@@ -259,7 +262,7 @@ connection master;
select "--- Test 5 LOAD DATA --" as ""; select "--- Test 5 LOAD DATA --" as "";
--enable_query_log --enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=106 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$binlog_start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# Bug#7853 (mysqlbinlog does not accept input from stdin) # Bug#7853 (mysqlbinlog does not accept input from stdin)
...@@ -267,14 +270,17 @@ select "--- Test 5 LOAD DATA --" as ""; ...@@ -267,14 +270,17 @@ select "--- Test 5 LOAD DATA --" as "";
select "--- Test 6 reading stdin --" as ""; select "--- Test 6 reading stdin --" as "";
--enable_query_log --enable_query_log
let $MYSQLD_DATADIR= `select @@datadir;`; let $MYSQLD_DATADIR= `select @@datadir;`;
let $stop_pos= `select @binlog_start_pos + 463`;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001 --exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
--disable_query_log --disable_query_log
select "--- Test 7 reading stdin w/position --" as ""; select "--- Test 7 reading stdin w/position --" as "";
--enable_query_log --enable_query_log
let $start_pos= `select @binlog_start_pos + 310`;
let $stop_pos= `select @binlog_start_pos + 463`;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --position=416 --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001 --exec $MYSQL_BINLOG --short-form --position=$start_pos --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
# Bug#16217 (mysql client did not know how not switch its internal charset) # Bug#16217 (mysql client did not know how not switch its internal charset)
--disable_query_log --disable_query_log
......
# depends on the binlog output # depends on the binlog output
--source include/have_binlog_format_mixed_or_statement.inc --source include/have_binlog_format_mixed_or_statement.inc
--source include/binlog_start_pos.inc
let $rename_event_pos= 684; let $rename_event_pos= `select @binlog_start_pos + 578`;
-- source extra/rpl_tests/rpl_flsh_tbls.test -- source extra/rpl_tests/rpl_flsh_tbls.test
...@@ -28,14 +28,6 @@ delimiter ;| ...@@ -28,14 +28,6 @@ delimiter ;|
--echo End of 5.0 tests --echo End of 5.0 tests
#
# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump
# Note: 364 is a magic position (found experimentally, depends on
# the log's contents) that caused the server crash.
--error 1220
SHOW BINLOG EVENTS FROM 365;
--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. --echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932; CREATE TABLE t1 (a varchar(16)) character set cp932;
INSERT INTO t1 VALUES (0x8372835E),(0x8352835E); INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
......
--source include/have_debug_sync.inc
--source include/have_innodb.inc
--source include/have_log_bin.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (k INT NOT NULL, a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, PRIMARY KEY(k)) ENGINE=InnoDB;
INSERT INTO t1 (k, a, b, c) VALUES (1, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (2, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (3, 0, 0, 0);
INSERT INTO t1 (k, a, b, c) VALUES (4, 0, 0, 0);
RESET MASTER;
SET DEBUG_SYNC= 'RESET';
# Two transactions A,B that update the same row.
# A releases row locks during the prepare phase, and waits using DEBUG_SYNC.
# B then updates the same row.
# Verify that
# - B's update can proceed while A is waiting for commit, showing that
# locks are released early.
# - B cannot be binlogged before A.
connect(c1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect(c2,127.0.0.1,root,,test,$MASTER_MYPORT,);
connection c1;
--echo # Connection c1
# Fix binlog format (otherwise SHOW BINLOG EVENTS will fluctuate).
SET binlog_format= mixed;
# First verify that row locks are released early.
BEGIN;
UPDATE t1 SET a=10 WHERE k=1;
# Wait until c2 starts COMMIT, to verify that we release our locks in prepare.
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committing";
send COMMIT;
connection c2;
--echo # Connection c2
SET binlog_format= mixed;
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
BEGIN;
SELECT * FROM t1 WHERE k=1 FOR UPDATE;
UPDATE t1 SET a=20 WHERE k=1;
SET DEBUG_SYNC="now SIGNAL c2_committing";
COMMIT;
connection c1;
--echo # Connection c1
reap;
# Now verify that binlog order is correct.
BEGIN;
UPDATE t1 SET a=10 WHERE k=2;
# This time wait until c2 is binlogged. This should time out, as we must not
# allow c2 to finish commit before c1.
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committed TIMEOUT 2";
send COMMIT;
connection c2;
--echo # Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
BEGIN;
SELECT * FROM t1 WHERE k=2 FOR UPDATE;
UPDATE t1 SET a=20 WHERE k=2;
SET DEBUG_SYNC="binlog_after_log_and_order SIGNAL c2_committed";
send COMMIT;
connection c1;
--echo # Connection c1
--echo # This should warn about DEBUG_SYNC timeout
reap;
connection c2;
--echo # Connection c2
reap;
--replace_column 2 # 5 #
--replace_regex /xid=[0-9]+/xid=XX/
SHOW BINLOG EVENTS LIMIT 2,12;
connection c1;
--echo # Connection c1
# Now the same thing, but using autocommit.
RESET MASTER;
# First verify that row locks are released early.
# Wait until c2 starts COMMIT, to verify that we release our locks in prepare.
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committing";
send UPDATE t1 SET a=10 WHERE k=3;
connection c2;
--echo # Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
SELECT * FROM t1 WHERE k=3 FOR UPDATE;
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c2_committing";
UPDATE t1 SET a=20 WHERE k=3;
connection c1;
--echo # Connection c1
reap;
# Now verify that binlog order is correct, this time with autocommit.
# This time wait until c2 is binlogged. This should time out, as we must not
# allow c2 to finish commit before c1.
SET DEBUG_SYNC="commit_after_release_LOCK_prepare_ordered SIGNAL c1_prepared WAIT_FOR c2_committed TIMEOUT 2";
send UPDATE t1 SET a=10 WHERE k=4;
connection c2;
--echo # Connection c2
SET DEBUG_SYNC="now WAIT_FOR c1_prepared";
SELECT * FROM t1 WHERE k=4 FOR UPDATE;
SET DEBUG_SYNC="binlog_after_log_and_order SIGNAL c2_committed";
send UPDATE t1 SET a=20 WHERE k=4;
connection c1;
--echo # Connection c1
--echo # This should warn about DEBUG_SYNC timeout
reap;
connection c2;
--echo # Connection c2
reap;
--replace_column 2 # 5 #
--replace_regex /xid=[0-9]+/xid=XX/
SHOW BINLOG EVENTS LIMIT 1,12;
SELECT * FROM t1 ORDER BY k;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
--max-binlog-size=4096
--force-restart --force-restart
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# TODO: Need to look at making row based version once new binlog client is complete. # TODO: Need to look at making row based version once new binlog client is complete.
-- source include/have_binlog_format_mixed_or_statement.inc -- source include/have_binlog_format_mixed_or_statement.inc
-- source include/binlog_start_pos.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
...@@ -50,15 +50,19 @@ select "--- offset --" as ""; ...@@ -50,15 +50,19 @@ select "--- offset --" as "";
--disable_query_log --disable_query_log
select "--- start-position --" as ""; select "--- start-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 let $start_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log --disable_query_log
select "--- stop-position --" as ""; select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLD_DATADIR/master-bin.000001 let $stop_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log --disable_query_log
select "--- start and stop positions ---" as ""; select "--- start and stop positions ---" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLD_DATADIR/master-bin.000001 let $start_pos= `select @binlog_start_pos + 502`;
let $stop_pos= `select @binlog_start_pos + 619`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos $MYSQLD_DATADIR/master-bin.000001
--disable_query_log --disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
...@@ -84,11 +88,13 @@ select "--- offset --" as ""; ...@@ -84,11 +88,13 @@ select "--- offset --" as "";
--disable_query_log --disable_query_log
select "--- start-position --" as ""; select "--- start-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 let $start_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
--disable_query_log --disable_query_log
select "--- stop-position --" as ""; select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=134 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002 let $stop_pos= `select @binlog_start_pos + 28`;
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
--disable_query_log --disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
...@@ -111,15 +117,19 @@ select "--- offset --" as ""; ...@@ -111,15 +117,19 @@ select "--- offset --" as "";
--disable_query_log --disable_query_log
select "--- start-position --" as ""; select "--- start-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 let $start_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log --disable_query_log
select "--- stop-position --" as ""; select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 let $stop_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log --disable_query_log
select "--- start and stop positions ---" as ""; select "--- start and stop positions ---" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 let $start_pos= `select @binlog_start_pos + 502`;
let $stop_pos= `select @binlog_start_pos + 619`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log --disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
...@@ -142,11 +152,13 @@ select "--- offset --" as ""; ...@@ -142,11 +152,13 @@ select "--- offset --" as "";
--disable_query_log --disable_query_log
select "--- start-position --" as ""; select "--- start-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 let $start_pos= `select @binlog_start_pos + 502`;
--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log --disable_query_log
select "--- stop-position --" as ""; select "--- stop-position --" as "";
--enable_query_log --enable_query_log
--exec $MYSQL_BINLOG --short-form --stop-position=134 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 let $stop_pos= `select @binlog_start_pos + 28`;
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log --disable_query_log
select "--- start-datetime --" as ""; select "--- start-datetime --" as "";
--enable_query_log --enable_query_log
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_archive.inc --source include/have_archive.inc
--source include/have_log_bin.inc
--disable_warnings --disable_warnings
drop table if exists t1, t2, t3, t4, t5, t6; drop table if exists t1, t2, t3, t4, t5, t6;
...@@ -1124,3 +1125,84 @@ DROP VIEW v1; ...@@ -1124,3 +1125,84 @@ DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL storage_engine=@old_engine; SET GLOBAL storage_engine=@old_engine;
# Test fully non-locking mysqldump with consistent binlog position (MWL#136).
connect(c1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect(c2,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect(c3,127.0.0.1,root,,test,$MASTER_MYPORT,);
connection default;
--echo # Connection default
SET binlog_format= mixed;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,0), (2,0);
SELECT GET_LOCK("block_queries_1", 120);
connection c3;
--echo # Connection c3
SELECT GET_LOCK("block_queries_2", 120);
# Start two queries that will be running on the tables during mysqldump
connection c1;
--echo # Connection c1
SET @c= 0;
send SELECT IF(@c<1, @c:=@c+1, GET_LOCK("block_queries_1", 120)) FROM t1 ORDER BY a;
connection c2;
--echo # Connection c2
SET binlog_format="row";
SET @d= 10;
send UPDATE t2 SET b=IF(@d<=10, @d:=@d+1, GET_LOCK("block_queries_2", 120)) ORDER BY a;
connection default;
--echo # Connection default
--echo # Make sure other queries are running (and waiting).
let $wait_condition=
SELECT COUNT(*) FROM information_schema.processlist
WHERE state = "User lock" AND info LIKE 'SELECT%block_queries_1%';
--source include/wait_condition.inc
let $wait_condition=
SELECT COUNT(*) FROM information_schema.processlist
WHERE state = "User lock" AND info LIKE 'UPDATE%block_queries_2%';
--source include/wait_condition.inc
--exec $MYSQL_DUMP --master-data=2 --single-transaction test t1 t2 > $MYSQLTEST_VARDIR/tmp/mwl136.sql
SELECT RELEASE_LOCK("block_queries_1");
connection c3;
--echo # Connection c3
SELECT RELEASE_LOCK("block_queries_2");
connection c1;
--echo # Connection c1
reap;
connection c2;
--echo # Connection c2
reap;
connection default;
--echo # Connection default
SELECT * FROM t2 ORDER BY a;
DROP TABLE t1;
DROP TABLE t2;
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mwl136.sql
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
SHOW BINLOG EVENTS LIMIT 6,3;
--perl
my $f= "$ENV{MYSQLTEST_VARDIR}/tmp/mwl136.sql";
open F, '<', $f or die "Failed to open $f: $!\n";
while (<F>) {
print if /CHANGE MASTER TO/;
}
EOF
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
DROP TABLE t1,t2;
--source include/have_innodb.inc
--source include/have_log_bin.inc
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
# Fix binlog format (otherwise SHOW BINLOG EVENTS will fluctuate).
SET binlog_format= mixed;
RESET MASTER;
XA START 'xatest';
INSERT INTO t1 VALUES (1);
XA END 'xatest';
XA PREPARE 'xatest';
XA COMMIT 'xatest';
XA START 'xatest';
INSERT INTO t1 VALUES (2);
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
BEGIN;
INSERT INTO t1 VALUES (3);
COMMIT;
SELECT * FROM t1 ORDER BY a;
--replace_column 2 # 5 #
--replace_regex /xid=[0-9]+/xid=XX/
SHOW BINLOG EVENTS LIMIT 1,9;
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -688,7 +688,11 @@ protected: ...@@ -688,7 +688,11 @@ protected:
/* BINLOG_DUMP options */ /* BINLOG_DUMP options */
#define BINLOG_DUMP_NON_BLOCK 1 #define BINLOG_DUMP_NON_BLOCK 1
#endif /* !MYSQL_CLIENT */
#define BINLOG_SEND_ANNOTATE_ROWS_EVENT 2
#ifndef MYSQL_CLIENT
/* sql_show.cc:show_log_files() */ /* sql_show.cc:show_log_files() */
#define SHOW_LOG_STATUS_FREE "FREE" #define SHOW_LOG_STATUS_FREE "FREE"
#define SHOW_LOG_STATUS_INUSE "IN USE" #define SHOW_LOG_STATUS_INUSE "IN USE"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -183,6 +183,9 @@ static sys_var_const sys_back_log(&vars, "back_log", ...@@ -183,6 +183,9 @@ static sys_var_const sys_back_log(&vars, "back_log",
OPT_GLOBAL, SHOW_LONG, OPT_GLOBAL, SHOW_LONG,
(uchar*) &back_log); (uchar*) &back_log);
static sys_var_const_os_str sys_basedir(&vars, "basedir", mysql_home); static sys_var_const_os_str sys_basedir(&vars, "basedir", mysql_home);
static sys_var_thd_bool
sys_binlog_annotate_rows_events(&vars, "binlog_annotate_rows_events",
&SV::binlog_annotate_rows_events);
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size", static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size",
&binlog_cache_size); &binlog_cache_size);
static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format", static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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