MCPcopy Create free account
hub / github.com/MariaDB/server / wait_for_master

Function wait_for_master

sql/sql_table.cc:10395–10435  ·  view source on GitHub ↗

Wait for master to send result of Alter table. Returns true when Rollback is decided false otherwise */

Source from the content-addressed store, hash-verified

10393 false otherwise
10394*/
10395static bool wait_for_master(THD *thd)
10396{
10397#ifdef HAVE_REPLICATION
10398 start_alter_info* info= thd->rgi_slave->sa_info;
10399 Master_info *mi= thd->rgi_slave->rli->mi;
10400
10401 DBUG_ASSERT(info);
10402 DBUG_ASSERT(info->state != start_alter_state::INVALID);
10403 DBUG_ASSERT(mi);
10404
10405 mysql_mutex_lock(&mi->start_alter_lock);
10406
10407 DBUG_ASSERT(!info->direct_commit_alter ||
10408 info->state == start_alter_state::ROLLBACK_ALTER);
10409
10410 while (info->state == start_alter_state::REGISTERED)
10411 {
10412 mysql_cond_wait(&info->start_alter_cond, &mi->start_alter_lock);
10413 }
10414 if (info->state == start_alter_state::ROLLBACK_ALTER)
10415 {
10416 /*
10417 SA thread will not give error , We will set the error in info->error
10418 and then RA worker will output the error
10419 We can modify the info->error without taking mutex, because CA worker
10420 will be waiting on ::COMPLETED wait condition
10421 */
10422 if(thd->is_error())
10423 {
10424 info->error= thd->get_stmt_da()->sql_errno();
10425 thd->clear_error();
10426 thd->reset_killed();
10427 }
10428 }
10429 mysql_mutex_unlock(&mi->start_alter_lock);
10430
10431 return info->state == start_alter_state::ROLLBACK_ALTER;
10432#else
10433 return 0;
10434#endif
10435}
10436
10437#ifdef HAVE_REPLICATION
10438/**

Callers 5

process_master_stateFunction · 0.85
mysql_alter_tableFunction · 0.85
copy_data_between_tablesFunction · 0.85

Calls 5

sql_errnoMethod · 0.80
get_stmt_daMethod · 0.80
reset_killedMethod · 0.80
is_errorMethod · 0.45
clear_errorMethod · 0.45

Tested by

no test coverage detected