Skip to content

Commit 126523d

Browse files
committed
MDEV-6703 Add "mysqlbinlog --binlog-row-event-max-size" support
partially cherry-pick from mysql/5.6. No test case (mysql/5.6 test case is useless, the correct test case uses too much memory) commit e061985813db54948f99892d89f7e076242473a5 Author: <Dao-Gang.Qu@sun.com> Date: Tue Jun 1 15:02:22 2010 +0800 Bug #49931 Incorrect type in read_log_event error Bug #49932 mysqlbinlog max_allowed_packet hard coded to 1GB
1 parent 73033e5 commit 126523d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

client/mysqlbinlog.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
#include "mysqld.h"
5151

52+
#include <algorithm>
53+
5254
Rpl_filter *binlog_filter= 0;
5355

5456
#define BIN_LOG_HEADER_SIZE 4
@@ -67,6 +69,7 @@ ulong server_id = 0;
6769
ulong bytes_sent = 0L, bytes_received = 0L;
6870
ulong mysqld_net_retry_count = 10L;
6971
ulong open_files_limit;
72+
ulong opt_binlog_rows_event_max_size;
7073
uint test_flags = 0;
7174
static uint opt_protocol= 0;
7275
static FILE *result_file;
@@ -1436,6 +1439,12 @@ that may lead to an endless loop.",
14361439
"Used to reserve file descriptors for use by this program.",
14371440
&open_files_limit, &open_files_limit, 0, GET_ULONG,
14381441
REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
1442+
{"binlog-row-event-max-size", 0,
1443+
"The maximum size of a row-based binary log event in bytes. Rows will be "
1444+
"grouped into events smaller than this size if possible. "
1445+
"This value must be a multiple of 256.",
1446+
&opt_binlog_rows_event_max_size, &opt_binlog_rows_event_max_size, 0,
1447+
GET_ULONG, REQUIRED_ARG, UINT_MAX, 256, ULONG_MAX, 0, 256, 0},
14391448
{"verify-binlog-checksum", 'c', "Verify checksum binlog events.",
14401449
(uchar**) &opt_verify_binlog_checksum, (uchar**) &opt_verify_binlog_checksum,
14411450
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},

sql/log_event.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
#define my_b_write_string(A, B) my_b_write((A), (B), (uint) (sizeof(B) - 1))
5454

55+
using std::max;
56+
5557
/**
5658
BINLOG_CHECKSUM variable.
5759
*/
@@ -1326,9 +1328,10 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
13261328
}
13271329
data_len= uint4korr(buf + EVENT_LEN_OFFSET);
13281330
if (data_len < LOG_EVENT_MINIMAL_HEADER_LEN ||
1329-
data_len > current_thd->variables.max_allowed_packet)
1331+
data_len > max(current_thd->variables.max_allowed_packet,
1332+
opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
13301333
{
1331-
DBUG_PRINT("error",("data_len: %ld", data_len));
1334+
DBUG_PRINT("error",("data_len: %lu", data_len));
13321335
result= ((data_len < LOG_EVENT_MINIMAL_HEADER_LEN) ? LOG_READ_BOGUS :
13331336
LOG_READ_TOO_LARGE);
13341337
goto end;
@@ -1449,7 +1452,7 @@ failed my_b_read"));
14491452
*/
14501453
DBUG_RETURN(0);
14511454
}
1452-
uint data_len = uint4korr(head + EVENT_LEN_OFFSET);
1455+
ulong data_len = uint4korr(head + EVENT_LEN_OFFSET);
14531456
char *buf= 0;
14541457
const char *error= 0;
14551458
Log_event *res= 0;
@@ -1458,7 +1461,8 @@ failed my_b_read"));
14581461
uint max_allowed_packet= thd ? slave_max_allowed_packet:~(uint)0;
14591462
#endif
14601463

1461-
if (data_len > max_allowed_packet)
1464+
if (data_len > max<ulong>(max_allowed_packet,
1465+
opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
14621466
{
14631467
error = "Event too big";
14641468
goto err;
@@ -1492,7 +1496,7 @@ failed my_b_read"));
14921496
{
14931497
DBUG_ASSERT(error != 0);
14941498
sql_print_error("Error in Log_event::read_log_event(): "
1495-
"'%s', data_len: %d, event_type: %d",
1499+
"'%s', data_len: %lu, event_type: %d",
14961500
error,data_len,(uchar)(head[EVENT_TYPE_OFFSET]));
14971501
my_free(buf);
14981502
/*

0 commit comments

Comments
 (0)