Commit cd873c86 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

debug_sync: Implement NO_CLEAR_EVENT syntax

When waiting on a signal, NO_CLEAR_EVENT allows one to not clear the
signal, effectively allowing other threads to wait for the same signal.
parent 8885225d
...@@ -299,4 +299,20 @@ disconnect con1; ...@@ -299,4 +299,20 @@ disconnect con1;
disconnect con2; disconnect con2;
connection default; connection default;
DROP TABLE t1; DROP TABLE t1;
#
# Test NO_CLEAR_EVENT flag. The signal should still be visible after
# the wait has completed succesfully.
#
SET DEBUG_SYNC= 'now SIGNAL s1';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signals: 's1'
SET DEBUG_SYNC= 'now WAIT_FOR s1 NO_CLEAR_EVENT';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signals: 's1'
SET DEBUG_SYNC= 'now WAIT_FOR s1';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signals: ''
SET DEBUG_SYNC= 'RESET'; SET DEBUG_SYNC= 'RESET';
...@@ -428,6 +428,17 @@ disconnect con2; ...@@ -428,6 +428,17 @@ disconnect con2;
connection default; connection default;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Test NO_CLEAR_EVENT flag. The signal should still be visible after
--echo # the wait has completed succesfully.
--echo #
SET DEBUG_SYNC= 'now SIGNAL s1';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'now WAIT_FOR s1 NO_CLEAR_EVENT';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'now WAIT_FOR s1';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
# #
# Cleanup after test case. # Cleanup after test case.
# Otherwise signal would contain 'flushed' here, # Otherwise signal would contain 'flushed' here,
......
...@@ -48,6 +48,8 @@ struct st_debug_sync_action ...@@ -48,6 +48,8 @@ struct st_debug_sync_action
String wait_for; /* signal to wait for */ String wait_for; /* signal to wait for */
String sync_point; /* sync point name */ String sync_point; /* sync point name */
bool need_sort; /* if new action, array needs sort */ bool need_sort; /* if new action, array needs sort */
bool clear_event; /* do not clear signal when waited
for if false. */
}; };
/* Debug sync control. Referenced by THD. */ /* Debug sync control. Referenced by THD. */
...@@ -1253,6 +1255,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) ...@@ -1253,6 +1255,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end)
/* Set default for EXECUTE and TIMEOUT options. */ /* Set default for EXECUTE and TIMEOUT options. */
action->execute= 1; action->execute= 1;
action->timeout= opt_debug_sync_timeout; action->timeout= opt_debug_sync_timeout;
action->clear_event= true;
/* Get next token. If none follows, set action. */ /* Get next token. If none follows, set action. */
if (!(ptr= debug_sync_token(&token, &token_length, ptr, action_end))) if (!(ptr= debug_sync_token(&token, &token_length, ptr, action_end)))
...@@ -1303,6 +1306,15 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) ...@@ -1303,6 +1306,15 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end)
goto set_action; goto set_action;
} }
/*
Try NO_CLEAR_EVENT.
*/
if (!my_strcasecmp(system_charset_info, token, "NO_CLEAR_EVENT")) {
action->clear_event= false;
/* Get next token. If none follows, set action. */
if (!(ptr = debug_sync_token(&token, &token_length, ptr, action_end))) goto set_action;
}
/* /*
Try HIT_LIMIT. Try HIT_LIMIT.
*/ */
...@@ -1591,8 +1603,10 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) ...@@ -1591,8 +1603,10 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
} }
error= 0; error= 0;
} }
// TODO conditional on clear-event
debug_sync_global.clear_signal(action->wait_for); if (action->clear_event)
debug_sync_global.clear_signal(action->wait_for);
DBUG_EXECUTE("debug_sync_exec", DBUG_EXECUTE("debug_sync_exec",
if (thd->killed) if (thd->killed)
DBUG_PRINT("debug_sync_exec", DBUG_PRINT("debug_sync_exec",
......
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