Commit a9ca9403 authored by Manish Kumar's avatar Manish Kumar

BUG#12400221 - 60926: BINARY LOG EVENTS LARGER THAN MAX_ALLOWED_PACKET

Problem
========
            
Replication breaks in the cases if the event length exceeds 
the size of master Dump thread's max_allowed_packet.
              
The reason why this failure is occuring is because the event length is
more than the total size of the max_allowed_packet, on addition of the  
max_event_header length exceeds the max_allowed_packet of the DUMP thread.
This causes the Dump thread to break replication and throw an error.
                      
That can happen e.g with row-based replication in Update_rows event.
            
Fix
====
          
The problem is fixed in 2 steps:

1.) The Dump thread limit to read event is increased to the upper limit
    i.e. Dump thread reads whatever gets logged in the binary log.

2.) On the slave side we increase the the max_allowed_packet for the
    slave's threads (IO/SQL) by increasing it to 1GB.

    This is done using the new server option (slave_max_allowed_packet)
    included, is used to regulate the max_allowed_packet of the  
    slave thread (IO/SQL) by the DBA, and facilitates the sending of
    large packets from the master to the slave.

    This causes the large packets to be received by the slave and apply
    it successfully.

sql/log_event.cc:
  The max_allowed_packet is not evaluated to the new option 
  slave_max_allowed_packet after the fix.
sql/log_event.h:
  Added the new option in the log_event.h file.
sql/mysqld.cc:
  Added a new option to the server.
sql/slave.cc:
  Increasing the session max_allowed_packet to a large value,
  i.e. not taking global(max_allowed) into consideration, for the slave's threads.
sql/sql_repl.cc:
  The dump thread's max_allowed_packet is set to the upper limit
  which makes it independent and it now reads whatever gets 
  logged in the binary log.
parents d8b2d4a0 1605b7f6
...@@ -9,7 +9,7 @@ change master to master_log_pos=MASTER_LOG_POS; ...@@ -9,7 +9,7 @@ change master to master_log_pos=MASTER_LOG_POS;
Read_Master_Log_Pos = '75' Read_Master_Log_Pos = '75'
start slave; start slave;
include/wait_for_slave_io_error.inc [errno=1236] include/wait_for_slave_io_error.inc [errno=1236]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'' Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event''
include/stop_slave_sql.inc include/stop_slave_sql.inc
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
......
include/master-slave.inc include/master-slave.inc
[connection master] [connection master]
call mtr.add_suppression("Slave I/O: Got a packet bigger than 'max_allowed_packet' bytes, Error_code: 1153"); call mtr.add_suppression("Slave I/O: Got a packet bigger than 'slave_max_allowed_packet' bytes, Error_code: 1153");
call mtr.add_suppression("Slave I/O: Got fatal error 1236 from master when reading data from binary log:"); call mtr.add_suppression("Log entry on master is longer than slave_max_allowed_packet");
drop database if exists DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; drop database if exists DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
create database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; create database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
SET @@global.max_allowed_packet=1024; SET @@global.max_allowed_packet=1024;
...@@ -30,14 +30,14 @@ include/start_slave.inc ...@@ -30,14 +30,14 @@ include/start_slave.inc
CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM; CREATE TABLE `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
include/wait_for_slave_io_error.inc [errno=1153] include/wait_for_slave_io_error.inc [errno=1153]
Last_IO_Error = 'Got a packet bigger than 'max_allowed_packet' bytes' Last_IO_Error = 'Got a packet bigger than 'slave_max_allowed_packet' bytes'
include/stop_slave_sql.inc include/stop_slave_sql.inc
include/rpl_reset.inc include/rpl_reset.inc
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM; CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet)); INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
include/wait_for_slave_io_error.inc [errno=1236] include/wait_for_slave_io_error.inc [errno=1153]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'' Last_IO_Error = 'Got a packet bigger than 'slave_max_allowed_packet' bytes'
STOP SLAVE; STOP SLAVE;
RESET SLAVE; RESET SLAVE;
RESET MASTER; RESET MASTER;
...@@ -52,6 +52,7 @@ SET @@global.max_allowed_packet= 1024; ...@@ -52,6 +52,7 @@ SET @@global.max_allowed_packet= 1024;
Warnings: Warnings:
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SET @@global.net_buffer_length= 1024; SET @@global.net_buffer_length= 1024;
SET @@global.slave_max_allowed_packet= 1073741824;
DROP TABLE t1; DROP TABLE t1;
RESET SLAVE; RESET SLAVE;
include/rpl_end.inc include/rpl_end.inc
-O max_allowed_packet=1024 -O net_buffer_length=1024 -O max_allowed_packet=1024 -O net_buffer_length=1024 -O slave_max_allowed_packet=1024
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
# max-out size db name # max-out size db name
source include/master-slave.inc; source include/master-slave.inc;
source include/have_binlog_format_row.inc; source include/have_binlog_format_row.inc;
call mtr.add_suppression("Slave I/O: Got a packet bigger than 'max_allowed_packet' bytes, Error_code: 1153"); call mtr.add_suppression("Slave I/O: Got a packet bigger than 'slave_max_allowed_packet' bytes, Error_code: 1153");
call mtr.add_suppression("Slave I/O: Got fatal error 1236 from master when reading data from binary log:"); call mtr.add_suppression("Log entry on master is longer than slave_max_allowed_packet");
let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
disable_warnings; disable_warnings;
eval drop database if exists $db; eval drop database if exists $db;
...@@ -23,6 +22,7 @@ eval create database $db; ...@@ -23,6 +22,7 @@ eval create database $db;
connection master; connection master;
let $old_max_allowed_packet= `SELECT @@global.max_allowed_packet`; let $old_max_allowed_packet= `SELECT @@global.max_allowed_packet`;
let $old_net_buffer_length= `SELECT @@global.net_buffer_length`; let $old_net_buffer_length= `SELECT @@global.net_buffer_length`;
let $old_slave_max_allowed_packet= `SELECT @@global.slave_max_allowed_packet`;
SET @@global.max_allowed_packet=1024; SET @@global.max_allowed_packet=1024;
SET @@global.net_buffer_length=1024; SET @@global.net_buffer_length=1024;
...@@ -124,8 +124,8 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), R ...@@ -124,8 +124,8 @@ INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), R
connection slave; connection slave;
# The slave I/O thread must stop after receiving # The slave I/O thread must stop after receiving
# 1236=ER_MASTER_FATAL_ERROR_READING_BINLOG error message from master. # 1153 = ER_NET_PACKET_TOO_LARGE
--let $slave_io_errno= 1236 --let $slave_io_errno= 1153
--let $show_slave_io_error= 1 --let $show_slave_io_error= 1
--source include/wait_for_slave_io_error.inc --source include/wait_for_slave_io_error.inc
...@@ -166,6 +166,7 @@ connection master; ...@@ -166,6 +166,7 @@ connection master;
DROP TABLE t1; DROP TABLE t1;
eval SET @@global.max_allowed_packet= $old_max_allowed_packet; eval SET @@global.max_allowed_packet= $old_max_allowed_packet;
eval SET @@global.net_buffer_length= $old_net_buffer_length; eval SET @@global.net_buffer_length= $old_net_buffer_length;
eval SET @@global.slave_max_allowed_packet= $old_slave_max_allowed_packet;
# slave is stopped # slave is stopped
connection slave; connection slave;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -1122,7 +1122,7 @@ failed my_b_read")); ...@@ -1122,7 +1122,7 @@ failed my_b_read"));
Log_event *res= 0; Log_event *res= 0;
#ifndef max_allowed_packet #ifndef max_allowed_packet
THD *thd=current_thd; THD *thd=current_thd;
uint max_allowed_packet= thd ? thd->variables.max_allowed_packet : ~(ulong)0; uint max_allowed_packet= thd ? slave_max_allowed_packet:~(ulong)0;
#endif #endif
if (data_len > max_allowed_packet) if (data_len > max_allowed_packet)
......
...@@ -275,6 +275,13 @@ struct sql_ex_info ...@@ -275,6 +275,13 @@ struct sql_ex_info
MAX_SIZE_LOG_EVENT_STATUS + /* status */ \ MAX_SIZE_LOG_EVENT_STATUS + /* status */ \
NAME_LEN + 1) NAME_LEN + 1)
/*
The new option is added to handle large packets that are sent from the master
to the slave. It is used to increase the thd(max_allowed) for both the
DUMP thread on the master and the SQL/IO thread on the slave.
*/
#define MAX_MAX_ALLOWED_PACKET 1024*1024*1024
/* /*
Event header offsets; Event header offsets;
these point to places inside the fixed header. these point to places inside the fixed header.
......
...@@ -1944,6 +1944,7 @@ extern ulong slave_net_timeout, slave_trans_retries; ...@@ -1944,6 +1944,7 @@ extern ulong slave_net_timeout, slave_trans_retries;
extern uint max_user_connections; extern uint max_user_connections;
extern ulong what_to_log,flush_time; extern ulong what_to_log,flush_time;
extern ulong query_buff_size; extern ulong query_buff_size;
extern ulong slave_max_allowed_packet;
extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong max_prepared_stmt_count, prepared_stmt_count;
extern ulong binlog_cache_size, open_files_limit; extern ulong binlog_cache_size, open_files_limit;
extern ulonglong max_binlog_cache_size; extern ulonglong max_binlog_cache_size;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "mysys_err.h" #include "mysys_err.h"
#include "events.h" #include "events.h"
#include "debug_sync.h" #include "debug_sync.h"
#include "log_event.h"
#include "../storage/myisam/ha_myisam.h" #include "../storage/myisam/ha_myisam.h"
...@@ -574,6 +575,7 @@ static const char *slave_exec_mode_str= "STRICT"; ...@@ -574,6 +575,7 @@ static const char *slave_exec_mode_str= "STRICT";
ulong thread_cache_size=0, thread_pool_size= 0; ulong thread_cache_size=0, thread_pool_size= 0;
ulong binlog_cache_size=0; ulong binlog_cache_size=0;
ulonglong max_binlog_cache_size=0; ulonglong max_binlog_cache_size=0;
ulong slave_max_allowed_packet= 0;
ulong query_cache_size=0; ulong query_cache_size=0;
ulong refresh_version; /* Increments on each reload */ ulong refresh_version; /* Increments on each reload */
query_id_t global_query_id; query_id_t global_query_id;
...@@ -5572,6 +5574,7 @@ enum options_mysqld ...@@ -5572,6 +5574,7 @@ enum options_mysqld
OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD, OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
OPT_LONG_QUERY_TIME, OPT_LONG_QUERY_TIME,
OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET, OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
OPT_SLAVE_MAX_ALLOWED_PACKET,
OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE, OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS, OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
OPT_MAX_DELAYED_THREADS, OPT_MAX_HEP_TABLE_SIZE, OPT_MAX_DELAYED_THREADS, OPT_MAX_HEP_TABLE_SIZE,
...@@ -6700,6 +6703,10 @@ thread is in the relay logs.", ...@@ -6700,6 +6703,10 @@ thread is in the relay logs.",
&global_system_variables.max_allowed_packet, &global_system_variables.max_allowed_packet,
&max_system_variables.max_allowed_packet, 0, GET_ULONG, &max_system_variables.max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"slave_max_allowed_packet", OPT_SLAVE_MAX_ALLOWED_PACKET,
"The maximum packet length to sent successfully from the master to slave.",
&slave_max_allowed_packet, &slave_max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, MAX_MAX_ALLOWED_PACKET, 1024, MAX_MAX_ALLOWED_PACKET, MALLOC_OVERHEAD, 1024, 0},
{"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
"Can be used to restrict the total size used to cache a multi-transaction query.", "Can be used to restrict the total size used to cache a multi-transaction query.",
&max_binlog_cache_size, &max_binlog_cache_size, 0, &max_binlog_cache_size, &max_binlog_cache_size, 0,
......
...@@ -366,6 +366,8 @@ static sys_var_const sys_lower_case_table_names(&vars, ...@@ -366,6 +366,8 @@ static sys_var_const sys_lower_case_table_names(&vars,
static sys_var_thd_ulong_session_readonly sys_max_allowed_packet(&vars, "max_allowed_packet", static sys_var_thd_ulong_session_readonly sys_max_allowed_packet(&vars, "max_allowed_packet",
&SV::max_allowed_packet, &SV::max_allowed_packet,
check_max_allowed_packet); check_max_allowed_packet);
static sys_var_long_ptr sys_slave_max_allowed_packet(&vars, "slave_max_allowed_packet",
&slave_max_allowed_packet);
static sys_var_ulonglong_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size", static sys_var_ulonglong_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
&max_binlog_cache_size); &max_binlog_cache_size);
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size", static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
......
...@@ -1884,8 +1884,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) ...@@ -1884,8 +1884,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
slave threads, since a replication event can become this much larger slave threads, since a replication event can become this much larger
than the corresponding packet (query) sent from client to master. than the corresponding packet (query) sent from client to master.
*/ */
thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet thd->variables.max_allowed_packet= slave_max_allowed_packet;
+ MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
thd->slave_thread = 1; thd->slave_thread = 1;
thd->enable_slow_log= opt_log_slow_slave_statements; thd->enable_slow_log= opt_log_slow_slave_statements;
set_slave_thread_options(thd); set_slave_thread_options(thd);
...@@ -2630,6 +2629,7 @@ pthread_handler_t handle_slave_io(void *arg) ...@@ -2630,6 +2629,7 @@ pthread_handler_t handle_slave_io(void *arg)
thread, since a replication event can become this much larger than thread, since a replication event can become this much larger than
the corresponding packet (query) sent from client to master. the corresponding packet (query) sent from client to master.
*/ */
thd->net.max_packet_size= slave_max_allowed_packet;
mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER; mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
} }
else else
...@@ -2761,12 +2761,12 @@ reading event")) ...@@ -2761,12 +2761,12 @@ reading event"))
switch (mysql_error_number) { switch (mysql_error_number) {
case CR_NET_PACKET_TOO_LARGE: case CR_NET_PACKET_TOO_LARGE:
sql_print_error("\ sql_print_error("\
Log entry on master is longer than max_allowed_packet (%ld) on \ Log entry on master is longer than slave_max_allowed_packet (%lu) on \
slave. If the entry is correct, restart the server with a higher value of \ slave. If the entry is correct, restart the server with a higher value of \
max_allowed_packet", slave_max_allowed_packet",
thd->variables.max_allowed_packet); slave_max_allowed_packet);
mi->report(ERROR_LEVEL, ER_NET_PACKET_TOO_LARGE, mi->report(ERROR_LEVEL, ER_NET_PACKET_TOO_LARGE,
"%s", ER(ER_NET_PACKET_TOO_LARGE)); "%s", "Got a packet bigger than 'slave_max_allowed_packet' bytes");
goto err; goto err;
case ER_MASTER_FATAL_ERROR_READING_BINLOG: case ER_MASTER_FATAL_ERROR_READING_BINLOG:
mi->report(ERROR_LEVEL, ER_MASTER_FATAL_ERROR_READING_BINLOG, mi->report(ERROR_LEVEL, ER_MASTER_FATAL_ERROR_READING_BINLOG,
......
...@@ -469,7 +469,7 @@ impossible position"; ...@@ -469,7 +469,7 @@ impossible position";
this larger than the corresponding packet (query) sent this larger than the corresponding packet (query) sent
from client to master. from client to master.
*/ */
thd->variables.max_allowed_packet+= MAX_LOG_EVENT_HEADER; thd->variables.max_allowed_packet= MAX_MAX_ALLOWED_PACKET;
/* /*
We can set log_lock now, it does not move (it's a member of We can set log_lock now, it does not move (it's a member of
......
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