Skip to content

Commit 1720fcd

Browse files
committed
cleanup DBUG, DBUG_DUMP_EVENT_BUF
introduce DBUG_DUMP_EVENT_BUF, remove few unused DBUG_EXECUTE_IF's simplify few DBUG_PRINT's remove few redundant #ifndef DBUG_OFF's
1 parent 781e18e commit 1720fcd

File tree

3 files changed

+31
-63
lines changed

3 files changed

+31
-63
lines changed

sql/log_event.cc

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,28 @@ pretty_print_str(String *packet, const char *str, int len)
519519
}
520520
#endif /* !MYSQL_CLIENT */
521521

522+
#ifndef DBUG_OFF
523+
#define DBUG_DUMP_EVENT_BUF(B,L) \
524+
do { \
525+
const uchar *_buf=(uchar*)(B); \
526+
size_t _len=(L); \
527+
if (_len >= LOG_EVENT_MINIMAL_HEADER_LEN) \
528+
{ \
529+
DBUG_PRINT("data", ("header: timestamp:%u type:%u server_id:%u len:%u log_pos:%u flags:%u", \
530+
uint4korr(_buf), _buf[EVENT_TYPE_OFFSET], \
531+
uint4korr(_buf+SERVER_ID_OFFSET), \
532+
uint4korr(_buf+EVENT_LEN_OFFSET), \
533+
uint4korr(_buf+LOG_POS_OFFSET), \
534+
uint4korr(_buf+FLAGS_OFFSET))); \
535+
DBUG_DUMP("data", _buf+LOG_EVENT_MINIMAL_HEADER_LEN, \
536+
_len-LOG_EVENT_MINIMAL_HEADER_LEN); \
537+
} \
538+
else \
539+
DBUG_DUMP("data", _buf, _len); \
540+
} while(0)
541+
#else
542+
#define DBUG_DUMP_EVENT_BUF(B,L) do { } while(0)
543+
#endif
522544

523545
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
524546

@@ -1433,7 +1455,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
14331455
DBUG_ENTER("Log_event::read_log_event(char*,...)");
14341456
DBUG_ASSERT(description_event != 0);
14351457
DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
1436-
DBUG_DUMP("data", (unsigned char*) buf, event_len);
1458+
DBUG_DUMP_EVENT_BUF(buf, event_len);
14371459

14381460
/* Check the integrity */
14391461
if (event_len < EVENT_LEN_OFFSET ||
@@ -1647,9 +1669,9 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
16471669
ev->crc= uint4korr(buf + (event_len));
16481670
}
16491671

1650-
DBUG_PRINT("read_event", ("%s(type_code: %d; event_len: %d)",
1672+
DBUG_PRINT("read_event", ("%s(type_code: %u; event_len: %u)",
16511673
ev ? ev->get_type_str() : "<unknown>",
1652-
buf[EVENT_TYPE_OFFSET],
1674+
(uchar)buf[EVENT_TYPE_OFFSET],
16531675
event_len));
16541676
/*
16551677
is_valid() are small event-specific sanity tests which are
@@ -6024,12 +6046,9 @@ Rotate_log_event::Rotate_log_event(const char* new_log_ident_arg,
60246046
pos(pos_arg),ident_len(ident_len_arg ? ident_len_arg :
60256047
(uint) strlen(new_log_ident_arg)), flags(flags_arg)
60266048
{
6027-
#ifndef DBUG_OFF
6028-
char buff[22];
60296049
DBUG_ENTER("Rotate_log_event::Rotate_log_event(...,flags)");
6030-
DBUG_PRINT("enter",("new_log_ident: %s pos: %s flags: %lu", new_log_ident_arg,
6031-
llstr(pos_arg, buff), (ulong) flags));
6032-
#endif
6050+
DBUG_PRINT("enter",("new_log_ident: %s pos: %llu flags: %lu", new_log_ident_arg,
6051+
pos_arg, (ulong) flags));
60336052
cache_type= EVENT_NO_CACHE;
60346053
if (flags & DUP_NAME)
60356054
new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
@@ -6098,14 +6117,11 @@ int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
60986117
{
60996118
Relay_log_info *rli= rgi->rli;
61006119
DBUG_ENTER("Rotate_log_event::do_update_pos");
6101-
#ifndef DBUG_OFF
6102-
char buf[32];
6103-
#endif
61046120

61056121
DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu",
61066122
(ulong) this->server_id, (ulong) global_system_variables.server_id));
61076123
DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident));
6108-
DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf)));
6124+
DBUG_PRINT("info", ("pos: %llu", this->pos));
61096125

61106126
/*
61116127
If we are in a transaction or in a group: the only normal case is
@@ -11192,11 +11208,9 @@ Rows_log_event::write_row(rpl_group_info *rgi,
1119211208
if (is_auto_inc_in_extra_columns())
1119311209
m_table->next_number_field->set_null();
1119411210

11195-
#ifndef DBUG_OFF
1119611211
DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
1119711212
DBUG_PRINT_BITSET("debug", "write_set = %s", table->write_set);
1119811213
DBUG_PRINT_BITSET("debug", "read_set = %s", table->read_set);
11199-
#endif
1120011214

1120111215
if (invoke_triggers &&
1120211216
process_triggers(TRG_EVENT_INSERT, TRG_ACTION_BEFORE, TRUE))
@@ -11305,11 +11319,9 @@ Rows_log_event::write_row(rpl_group_info *rgi,
1130511319
error= unpack_current_row(rgi);
1130611320
}
1130711321

11308-
#ifndef DBUG_OFF
1130911322
DBUG_PRINT("debug",("preparing for update: before and after image"));
1131011323
DBUG_DUMP("record[1] (before)", table->record[1], table->s->reclength);
1131111324
DBUG_DUMP("record[0] (after)", table->record[0], table->s->reclength);
11312-
#endif
1131311325

1131411326
/*
1131511327
REPLACE is defined as either INSERT or DELETE + INSERT. If
@@ -11669,10 +11681,8 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
1166911681
prepare_record(table, m_width, FALSE);
1167011682
error= unpack_current_row(rgi);
1167111683

11672-
#ifndef DBUG_OFF
1167311684
DBUG_PRINT("info",("looking for the following record"));
1167411685
DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
11675-
#endif
1167611686

1167711687
if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) &&
1167811688
table->s->primary_key < MAX_KEY)

sql/slave.cc

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,7 +3917,6 @@ pthread_handler_t handle_slave_io(void *arg)
39173917
int ret;
39183918
rpl_io_thread_info io_info;
39193919
#ifndef DBUG_OFF
3920-
uint retry_count_reg= 0, retry_count_dump= 0, retry_count_event= 0;
39213920
mi->dbug_do_disconnect= false;
39223921
#endif
39233922
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
@@ -4101,16 +4100,6 @@ pthread_handler_t handle_slave_io(void *arg)
41014100
goto err;
41024101
goto connected;
41034102
}
4104-
DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_REG",
4105-
if (!retry_count_reg)
4106-
{
4107-
retry_count_reg++;
4108-
sql_print_information("Forcing to reconnect slave I/O thread");
4109-
if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,
4110-
reconnect_messages[SLAVE_RECON_ACT_REG]))
4111-
goto err;
4112-
goto connected;
4113-
});
41144103
}
41154104

41164105
DBUG_PRINT("info",("Starting reading binary log from master"));
@@ -4127,16 +4116,7 @@ requesting master dump") ||
41274116
goto err;
41284117
goto connected;
41294118
}
4130-
DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_DUMP",
4131-
if (!retry_count_dump)
4132-
{
4133-
retry_count_dump++;
4134-
sql_print_information("Forcing to reconnect slave I/O thread");
4135-
if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,
4136-
reconnect_messages[SLAVE_RECON_ACT_DUMP]))
4137-
goto err;
4138-
goto connected;
4139-
});
4119+
41404120
const char *event_buf;
41414121

41424122
DBUG_ASSERT(mi->last_error().number == 0);
@@ -4154,16 +4134,6 @@ requesting master dump") ||
41544134
if (check_io_slave_killed(mi, "Slave I/O thread killed while \
41554135
reading event"))
41564136
goto err;
4157-
DBUG_EXECUTE_IF("FORCE_SLAVE_TO_RECONNECT_EVENT",
4158-
if (!retry_count_event)
4159-
{
4160-
retry_count_event++;
4161-
sql_print_information("Forcing to reconnect slave I/O thread");
4162-
if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,
4163-
reconnect_messages[SLAVE_RECON_ACT_EVENT]))
4164-
goto err;
4165-
goto connected;
4166-
});
41674137

41684138
if (event_len == packet_error)
41694139
{

sql/sql_repl.cc

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,18 +2073,6 @@ static int init_binlog_sender(binlog_send_info *info,
20732073
info->dbug_reconnect_counter= 22;
20742074
});
20752075

2076-
/*
2077-
We want to corrupt the first event, in Log_event::read_log_event().
2078-
But we do not want the corruption to happen early, eg. when client does
2079-
BINLOG_GTID_POS(). So test case sets a DBUG trigger which causes us to
2080-
set the real DBUG injection here.
2081-
*/
2082-
DBUG_EXECUTE_IF("corrupt_read_log_event2_set",
2083-
{
2084-
DBUG_SET("-d,corrupt_read_log_event2_set");
2085-
DBUG_SET("+d,corrupt_read_log_event2");
2086-
});
2087-
20882076
if (global_system_variables.log_warnings > 1)
20892077
sql_print_information(
20902078
"Start binlog_dump to slave_server(%lu), pos(%s, %lu)",
@@ -2798,9 +2786,9 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
27982786
BINLOG_GTID_POS(). So test case sets a DBUG trigger which causes us to
27992787
set the real DBUG injection here.
28002788
*/
2801-
DBUG_EXECUTE_IF("corrupt_read_log_event_to_slave_set",
2789+
DBUG_EXECUTE_IF("corrupt_read_log_event2_set",
28022790
{
2803-
DBUG_SET("-d,corrupt_read_log_event_to_slave_set");
2791+
DBUG_SET("-d,corrupt_read_log_event2_set");
28042792
DBUG_SET("+d,corrupt_read_log_event2");
28052793
});
28062794

0 commit comments

Comments
 (0)