28
28
#include < thread>
29
29
#include < utility>
30
30
31
- #include < my_dbug.h>
32
31
#include < my_sys.h>
33
32
#include < my_thread.h>
34
33
#include < mysqld_error.h>
40
39
41
40
#include < mysql/components/services/log_builtins.h>
42
41
#include < mysql/components/services/mysql_current_thread_reader.h>
42
+ #ifndef NDEBUG
43
+ #include < mysql/components/services/mysql_debug_keyword_service.h>
44
+ #include < mysql/components/services/mysql_debug_sync_service.h>
45
+ #endif
43
46
44
47
#include < mysql/components/services/bits/my_thread_bits.h>
45
48
#include < mysql/components/services/bits/psi_bits.h>
58
61
#endif
59
62
#include " masking_functions/static_sql_context_builder.hpp"
60
63
61
- #include " sql/debug_sync.h" // IWYU pragma: keep
62
-
63
64
extern REQUIRES_SERVICE_PLACEHOLDER (mysql_current_thread_reader);
65
+ #ifndef NDEBUG
66
+ extern REQUIRES_SERVICE_PLACEHOLDER (mysql_debug_keyword_service);
67
+ extern REQUIRES_SERVICE_PLACEHOLDER (mysql_debug_sync_service);
68
+ #endif
64
69
65
70
namespace {
66
71
@@ -294,25 +299,32 @@ void dictionary_flusher_thread::do_periodic_reload() {
294
299
}
295
300
cache = std::make_unique<term_cache>(cache_core_, sql_ctx_builder);
296
301
297
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-do-while)
298
- DBUG_EXECUTE_IF (" enable_masking_functions_flush_thread_sync" , {
302
+ // not using 'DBUG_EXECUTE_IF()' macro from the
303
+ // 'mysql/components/util/debug_execute_if.h' and 'DEBUG_SYNC()' macro
304
+ // fromthe 'mysql/components/util/debug_sync.h' as they are not supposed
305
+ // to be used in namespaces (including anonymous)
306
+ #ifndef NDEBUG
307
+ if (mysql_service_mysql_debug_keyword_service->lookup_debug_keyword (
308
+ " enable_masking_functions_flush_thread_sync" ) != 0 ) {
299
309
const sql_context_ptr sql_ctx{sql_ctx_builder->build ()};
300
310
std::string wait_action{
301
311
" SET debug_sync = 'masking_functions_before_cache_reload WAIT_FOR "
302
312
" masking_functions_before_cache_reload_signal" };
303
313
std::string signal_action{
304
314
" SET debug_sync = 'masking_functions_after_cache_reload SIGNAL "
305
315
" masking_functions_after_cache_reload_signal" };
306
- DBUG_EXECUTE_IF (" enable_masking_functions_flush_thread_double_pass" , {
316
+ if (mysql_service_mysql_debug_keyword_service->lookup_debug_keyword (
317
+ " enable_masking_functions_flush_thread_double_pass" ) != 0 ) {
307
318
wait_action += " EXECUTE 2" ;
308
319
signal_action += " EXECUTE 2" ;
309
- });
320
+ }
310
321
wait_action += ' \' ' ;
311
322
signal_action += ' \' ' ;
312
323
313
324
sql_ctx->execute_dml (wait_action);
314
325
sql_ctx->execute_dml (signal_action);
315
- });
326
+ }
327
+ #endif
316
328
} catch (const std::exception &e) {
317
329
failure_message.emplace (
318
330
" Exception during flusher thread initialization - " );
@@ -352,10 +364,13 @@ void dictionary_flusher_thread::do_periodic_reload() {
352
364
auto expires_at{std::chrono::steady_clock::now ()};
353
365
while (!is_terminated_lambda ()) {
354
366
if (std::chrono::steady_clock::now () >= expires_at) {
355
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-do-while)
356
- DBUG_EXECUTE_IF (" enable_masking_functions_flush_thread_sync" , {
357
- DEBUG_SYNC (extracted_thd, " masking_functions_before_cache_reload" );
358
- });
367
+ #ifndef NDEBUG
368
+ if (mysql_service_mysql_debug_keyword_service->lookup_debug_keyword (
369
+ " enable_masking_functions_flush_thread_sync" ) != 0 ) {
370
+ mysql_service_mysql_debug_sync_service->debug_sync (
371
+ extracted_thd, " masking_functions_before_cache_reload" );
372
+ }
373
+ #endif
359
374
360
375
failure_message.reset ();
361
376
try {
@@ -373,10 +388,13 @@ void dictionary_flusher_thread::do_periodic_reload() {
373
388
failure_message->c_str ());
374
389
}
375
390
376
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-do-while)
377
- DBUG_EXECUTE_IF (" enable_masking_functions_flush_thread_sync" , {
378
- DEBUG_SYNC (extracted_thd, " masking_functions_after_cache_reload" );
379
- });
391
+ #ifndef NDEBUG
392
+ if (mysql_service_mysql_debug_keyword_service->lookup_debug_keyword (
393
+ " enable_masking_functions_flush_thread_sync" ) != 0 ) {
394
+ mysql_service_mysql_debug_sync_service->debug_sync (
395
+ extracted_thd, " masking_functions_after_cache_reload" );
396
+ }
397
+ #endif
380
398
381
399
expires_at = std::chrono::steady_clock::now () + flush_interval_duration;
382
400
} else {
0 commit comments