From 0f2fe8bde7ea13cb01b642291a9e4277f9bf0ad6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Sep 2006 00:19:05 +0300 Subject: BUG#19402 SQL close to the size of the max_allowed_packet fails on the slave A communication packet can also be a binlog event sent from the master to the slave. To be sent by master dump and accepted by slave io thread both have to have the value of max_allowed_packet bigger than one that client connection had. In the patch there is the MAX possible replicatio header size estimation for events in binlog that embedded user query. Only these events of query_log_event type, i.e just plain queries, require attention. sql/log_event.h: MAX value of the header of the replication packet, i.e the value of exceeding the query string part. sql/slave.cc: Private value of max allowed packet slave io, sql threads can accept from master. The value is increased by the MAX possible size of replication event header. Note, that my_net_init is redundant for slave io because the thread uses instance of NET struct, embedded into MYSQL, as a client to server. We have left old code and even increment, redundantly as well, thd->net.max_packet_size just for the sake of consistency. TODO: eliminate my_net_init from execution path of slave io. sql/sql_repl.cc: Increasing the private max allowed packet that the dump thread reads from master binlog and sends to net. Note, that happened prior this writting to binlog is safe from the current artifact because it is done by steps that each chunk can not exceed @@global.max_allowed_packet. mysql-test/r/rpl_packet.result: BitKeeper file /home/elkin/MySQL/TEAM/FIXES/4.1/bug19402-max_allowed/mysql-test/r/rpl_packet.result mysql-test/t/rpl_packet-master.opt: BitKeeper file /net/koti/usr_rh9/home/elkin.rh9/MySQL/TEAM/FIXES/4.1/bug19402-max_allowed/mysql-test/t/rpl_packet-master.opt mysql-test/t/rpl_packet-slave.opt: BitKeeper file /net/koti/usr_rh9/home/elkin.rh9/MySQL/TEAM/FIXES/4.1/bug19402-max_allowed/mysql-test/t/rpl_packet-slave.opt mysql-test/t/rpl_packet.test: test examines repliation of a max-sized query when database name is set to have NAME_LEN bytes. This makes replication header size the maximum. --- sql/slave.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index b2862a437bb..7cf604ae3b1 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2618,6 +2618,8 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; thd->host_or_ip= ""; my_net_init(&thd->net, 0); + thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet + + MAX_LOG_EVENT_HEADER; /* reentering secured through using global */ thd->net.read_timeout = slave_net_timeout; thd->master_access= ~(ulong)0; thd->priv_user = 0; @@ -3143,16 +3145,20 @@ slave_begin: sql_print_error("Slave I/O thread: error in mysql_init()"); goto err; } - + thd->proc_info = "Connecting to master"; // we can get killed during safe_connect if (!safe_connect(thd, mysql, mi)) + { sql_print_information("Slave I/O thread: connected to master '%s@%s:%d',\ replication started in log '%s' at position %s", mi->user, - mi->host, mi->port, - IO_RPL_LOG_NAME, - llstr(mi->master_log_pos,llbuff)); + mi->host, mi->port, + IO_RPL_LOG_NAME, + llstr(mi->master_log_pos,llbuff)); + /* post-net-init for slave */ + mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER; + } else { sql_print_error("Slave I/O thread killed while connecting to master"); -- cgit v1.2.1 From 57ba34ff8a9e372137d701bbe2c08fd948095326 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Nov 2006 20:01:58 +0200 Subject: bug#19402 SQL close to the size of the max_allowed_packet fails on the slave comments are fixed as was suggested in reviews. sql/log_event.h: fixing comments sql/slave.cc: fixing comments sql/sql_repl.cc: fixing comments --- sql/slave.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index bc80d586ced..6785e92b9f9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2618,8 +2618,13 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; thd->host_or_ip= ""; my_net_init(&thd->net, 0); +/* + Adding MAX_LOG_EVENT_HEADER_LEN to the max_allowed_packet on all + slave threads, since a replication event can become this much larger + than the corresponding packet (query) sent from client to master. +*/ thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet - + MAX_LOG_EVENT_HEADER; /* reentering secured through using global */ + + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */ thd->net.read_timeout = slave_net_timeout; thd->master_access= ~(ulong)0; thd->priv_user = 0; @@ -3156,7 +3161,11 @@ slave_begin: mi->host, mi->port, IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff)); - /* post-net-init for slave */ + /* + Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O + thread, since a replication event can become this much larger than + the corresponding packet (query) sent from client to master. + */ mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER; } else -- cgit v1.2.1