Skip to content
Permalink
Browse files
MDEV-29613 Improve WITH_DBUG_TRACE=OFF
In commit 28325b0
a compile-time option was introduced to disable the macros
DBUG_ENTER and DBUG_RETURN or DBUG_VOID_RETURN.

The parameter name WITH_DBUG_TRACE would hint that it also
covers DBUG_PRINT statements. Let us do that: WITH_DBUG_TRACE=OFF
shall disable DBUG_PRINT() as well.

A few InnoDB recovery tests used to check that some output from
DBUG_PRINT("ib_log", ...) is present. We can live without those checks.

Reviewed by: Vladislav Vaintroub
  • Loading branch information
dr-m committed Sep 23, 2022
1 parent db7e04e commit a69cf6f
Show file tree
Hide file tree
Showing 31 changed files with 89 additions and 99 deletions.
@@ -248,9 +248,11 @@ ENDIF()

INCLUDE(wsrep)

OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_EXIT()" ON)
OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_RETURN()/DBUG_PRINT()" ON)
IF(WITH_DBUG_TRACE)
ADD_DEFINITIONS(-DDBUG_TRACE)
FOREACH(LANG C CXX)
SET(CMAKE_${LANG}_FLAGS_DEBUG "${CMAKE_${LANG}_FLAGS_DEBUG} -DDBUG_TRACE")
ENDFOREACH()
ENDIF()

# Always enable debug sync for debug builds.
@@ -6158,18 +6158,18 @@ static bool xtrabackup_prepare_func(char** argv)
{
for (int i= 0; i < got; i++)
{
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
int rc=
#endif // !DBUG_OFF
#endif
innobase_rollback_by_xid(NULL, xid_list + i);
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
if (rc == 0)
{
char buf[XIDDATASIZE * 4 + 6]; // see xid_to_str
DBUG_PRINT("info",
("rollback xid %s", xid_to_str(buf, xid_list[i])));
}
#endif // !DBUG_OFF
#endif
}
}
ut_d(recv_no_log_write= true);
@@ -74,6 +74,9 @@ extern int (*dbug_sanity)(void);
_db_stack_frame_.line= 0; \
} while(0)

#define DBUG_PRINT(keyword,arglist) \
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)

#ifdef HAVE_ATTRIBUTE_CLEANUP
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_ __attribute__((cleanup(_db_return_))); \
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
@@ -91,6 +94,7 @@ extern int (*dbug_sanity)(void);
#define DBUG_ENTER(a)
#define DBUG_RETURN(a1) return(a1)
#define DBUG_VOID_RETURN return
#define DBUG_PRINT(keyword,arglist) do{} while(0)
#endif

#define DBUG_EXECUTE(keyword,a1) \
@@ -101,8 +105,6 @@ extern int (*dbug_sanity)(void);
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1)
@@ -164,6 +166,7 @@ extern void _db_suicide_(void);
#define DBUG_LEAVE
#define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_PRINT(keyword, arglist) do { } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
@@ -15,7 +15,6 @@ set global debug_key_management_version=10;
select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10;
count(*)
0
SET GLOBAL debug_dbug = '+d,ib_log';
SET GLOBAL innodb_log_checkpoint_now = 1;
SET GLOBAL innodb_flush_log_at_trx_commit = 1;
INSERT INTO t1 VALUES(NULL);
@@ -25,7 +25,6 @@ let $wait_condition= select count(*) = $tables_count from information_schema.inn
select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10;

# Test redo log key rotation and crash recovery.
SET GLOBAL debug_dbug = '+d,ib_log';
SET GLOBAL innodb_log_checkpoint_now = 1;
SET GLOBAL innodb_flush_log_at_trx_commit = 1;
INSERT INTO t1 VALUES(NULL);
@@ -11,11 +11,8 @@ INSERT INTO t1 VALUES (1,2);
ALTER TABLE t1 ADD PRIMARY KEY(a), LOCK=SHARED, ALGORITHM=INPLACE;
ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
# Kill the server
# restart: --debug=d,ib_log
FOUND 2 /scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0/ in mysqld.1.err
FOUND 3 /scan \d+: log rec MLOG_INDEX_LOAD/ in mysqld.1.err
# restart
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
# restart
DROP TABLE t1;
@@ -9,10 +9,9 @@ CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND 1 /InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either/ in mysqld.1.err
# restart: --debug=d,innodb_log_abort_3,ib_log --innodb-log-files-in-group=1 --innodb-log-file-size=4M
# restart: --debug=d,innodb_log_abort_3 --innodb-log-files-in-group=1 --innodb-log-file-size=4M
SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB'
FOUND 1 /ib_log: MLOG_CHECKPOINT.* written/ in mysqld.1.err
# restart
# restart
DROP TABLE t1;
@@ -26,22 +26,7 @@ ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
--source include/no_checkpoint_end.inc

--let $restart_parameters= --debug=d,ib_log
--source include/start_mysqld.inc

let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_ABORT=NOT FOUND;
# ensure that we have exactly 2 records there.
let SEARCH_PATTERN=scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0;
--source include/search_pattern_in_file.inc
# ensure that we have exactly 3 records there.
let SEARCH_PATTERN=scan \d+: log rec MLOG_INDEX_LOAD;
--source include/search_pattern_in_file.inc

CHECK TABLE t1;

# Remove the --debug=d,ib_log setting.
--let $restart_parameters=
--source include/restart_mysqld.inc

DROP TABLE t1;
@@ -35,12 +35,10 @@ SELECT * FROM t1;
--let SEARCH_PATTERN = InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either
--source include/search_pattern_in_file.inc

--let $restart_parameters= --debug=d,innodb_log_abort_3,ib_log $resize
--let $restart_parameters= --debug=d,innodb_log_abort_3 $resize
--source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1;
--let SEARCH_PATTERN= ib_log: MLOG_CHECKPOINT.* written
--source include/search_pattern_in_file.inc

--let $restart_parameters=
--source include/restart_mysqld.inc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -376,7 +376,7 @@ static void keycache_debug_print(const char *fmt,...);
#define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a)
#endif /* defined(KEYCACHE_DEBUG_LOG) && defined(KEYCACHE_DEBUG) */

#if defined(KEYCACHE_DEBUG) || !defined(DBUG_OFF)
#if defined(KEYCACHE_DEBUG) || defined(DBUG_TRACE)
static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE(l) \
KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id))
@@ -392,7 +392,7 @@ static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE_BEGIN(l)
#define KEYCACHE_THREAD_TRACE_END(l)
#define KEYCACHE_THREAD_TRACE(l)
#endif /* defined(KEYCACHE_DEBUG) || !defined(DBUG_OFF) */
#endif /* defined(KEYCACHE_DEBUG) || defined(DBUG_TRACE) */

#define BLOCK_NUMBER(b) \
((uint) (((char*)(b)-(char *) keycache->block_root)/sizeof(BLOCK_LINK)))
@@ -1,5 +1,5 @@
/* Copyright (c) 2009, 2013, Oracle and/or its affiliates.
Copyright (c) 2013, 2020, MariaDB
Copyright (c) 2013, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -326,7 +326,7 @@ static char *debug_sync_bmove_len(char *to, char *to_end,
}


#if !defined(DBUG_OFF)
#ifdef DBUG_TRACE

/**
Create a string that describes an action.
@@ -416,8 +416,7 @@ static void debug_sync_print_actions(THD *thd)

DBUG_VOID_RETURN;
}

#endif /* !defined(DBUG_OFF) */
#endif /* defined(DBUG_TRACE) */


/**
@@ -748,6 +747,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
else
{
const char *dsp_name= action->sync_point.c_ptr();
#ifdef DBUG_TRACE
DBUG_EXECUTE("debug_sync", {
/* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_emit= action->signal.c_ptr();
@@ -758,6 +758,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
dsp_name, action->activation_count,
action->hit_limit, action->execute, action->timeout,
sig_emit, sig_wait));});
#endif

/* Check this before sorting the array. action may move. */
is_dsp_now= !my_strcasecmp(system_charset_info, dsp_name, "now");
@@ -770,7 +771,9 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
sizeof(st_debug_sync_action), debug_sync_qsort_cmp);
}
}
#ifdef DBUG_TRACE
DBUG_EXECUTE("debug_sync_list", debug_sync_print_actions(thd););
#endif

/* Execute the special sync point 'now' if activated above. */
if (is_dsp_now)
@@ -1334,7 +1337,7 @@ uchar *debug_sync_value_ptr(THD *thd)

static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
{
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
const char *dsp_name= action->sync_point.c_ptr();
const char *sig_emit= action->signal.c_ptr();
const char *sig_wait= action->wait_for.c_ptr();
@@ -1425,12 +1428,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
restore_current_mutex = false;

set_timespec(abstime, action->timeout);
DBUG_EXECUTE("debug_sync_exec", {
DBUG_EXECUTE("debug_sync_exec",
/* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
DBUG_PRINT("debug_sync_exec",
("wait for '%s' at: '%s' curr: '%s'",
sig_wait, dsp_name, sig_glob));});
sig_wait, dsp_name,
debug_sync_global.ds_signal.c_ptr())););

/*
Wait until global signal string matches the wait_for string.
@@ -1444,12 +1447,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
error= mysql_cond_timedwait(&debug_sync_global.ds_cond,
&debug_sync_global.ds_mutex,
&abstime);
DBUG_EXECUTE("debug_sync", {
DBUG_EXECUTE("debug_sync",
/* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
DBUG_PRINT("debug_sync",
("awoke from %s global: %s error: %d",
sig_wait, sig_glob, error));});
sig_wait, debug_sync_global.ds_signal.c_ptr(),
error)););
if (unlikely(error == ETIMEDOUT || error == ETIME))
{
// We should not make the statement fail, even if in strict mode.
@@ -538,7 +538,7 @@ Event_queue::empty_queue()
void
Event_queue::dbug_dump_queue(my_time_t when)
{
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
my_time_t now= when;
Event_queue_element *et;
uint i;
@@ -3269,7 +3269,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value,
DBUG_ASSERT(marked_for_write_or_computed());
int error= 0;
DBUG_ENTER("Field_new_decimal::store_value");
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
{
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, decimal_value)));
@@ -3284,7 +3284,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value,
error= 1;
decimal_value= &decimal_zero;
}
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
{
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("info", ("saving with precision %d scale: %d value %s",
@@ -3376,7 +3376,7 @@ int Field_new_decimal::store(const char *from, size_t length,
}
}

#ifndef DBUG_OFF
#ifdef DBUG_TRACE
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("enter", ("value: %s",
dbug_decimal_as_string(dbug_buff, &decimal_value)));
@@ -116,16 +116,20 @@ static void GCALC_DBUG_PRINT_PI(const Gcalc_heap::Info *pi)
int n_buf;
if (pi->type == Gcalc_heap::nt_intersection)
{
#ifdef DBUG_TRACE
const Gcalc_scan_iterator::intersection_info *ic= i_data(pi);

GCALC_DBUG_PRINT(("intersection point %d %d",
ic->edge_a->thread, ic->edge_b->thread));
#endif
return;
}
if (pi->type == Gcalc_heap::nt_eq_node)
{
#ifdef DBUG_TRACE
const Gcalc_scan_iterator::point *e= eq_sp(pi);
GCALC_DBUG_PRINT(("eq point %d", e->thread));
#endif
return;
}
n_buf= gcalc_pi_str(buf, pi, "");
@@ -726,7 +726,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
}
void harvest_bytes_written(Atomic_counter<uint64> *counter)
{
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
char buf1[22],buf2[22];
#endif
DBUG_ENTER("harvest_bytes_written");
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2021, MariaDB
Copyright (c) 2009, 2022, MariaDB

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4557,7 +4557,7 @@ static void copy_str_and_move(const char **src,
}


#ifndef DBUG_OFF
#ifdef DBUG_TRACE
static char const *
code_name(int code)
{
@@ -2278,7 +2278,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
MDL_ticket *ticket;
MDL_wait::enum_wait_status wait_status;
DBUG_ENTER("MDL_context::acquire_lock");
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
const char *mdl_lock_name= get_mdl_lock_name(
mdl_request->key.mdl_namespace(), mdl_request->type)->str;
#endif
@@ -2304,7 +2304,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
DBUG_RETURN(FALSE);
}

#ifndef DBUG_OFF
#ifdef DBUG_TRACE
const char *ticket_msg= dbug_print_mdl(ticket);
#endif

@@ -263,14 +263,14 @@ class injector
*/
int check_state(enum_state const target_state)
{
#ifndef DBUG_OFF
#ifdef DBUG_TRACE
static char const *state_name[] = {
"START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT"
};

DBUG_ASSERT(target_state <= STATE_COUNT);
DBUG_PRINT("info", ("In state %s", state_name[m_state]));
#endif
DBUG_ASSERT(target_state <= STATE_COUNT);

if (m_state <= target_state && target_state <= m_state + 1 &&
m_state < STATE_COUNT)

0 comments on commit a69cf6f

Please sign in to comment.