The function is invoked in error branches of ALTER processing. Write Rollback alter in case of partial_alter is true else call process_master_state. @param thd Thread handle. @param[in/out] start_alter_id Start Alter identifier or zero, it is reset to zero. @param[in/out] partial_alter When is true at the function ent
| 7949 | @return true otherwise |
| 7950 | */ |
| 7951 | static bool |
| 7952 | write_bin_log_start_alter_rollback(THD *thd, uint64 &start_alter_id, |
| 7953 | bool &partial_alter, bool if_exists) |
| 7954 | { |
| 7955 | #if defined(HAVE_REPLICATION) |
| 7956 | if (start_alter_id) |
| 7957 | { |
| 7958 | start_alter_info *info= thd->rgi_slave->sa_info; |
| 7959 | Master_info *mi= thd->rgi_slave->rli->mi; |
| 7960 | |
| 7961 | if (info->sa_seq_no == 0) |
| 7962 | { |
| 7963 | /* |
| 7964 | Error occurred before SA got to processing incl its binlogging. |
| 7965 | So it's a failure to apply and thus no need to wait for master's |
| 7966 | completion result. |
| 7967 | */ |
| 7968 | return true; |
| 7969 | } |
| 7970 | mysql_mutex_lock(&mi->start_alter_lock); |
| 7971 | if (info->direct_commit_alter) |
| 7972 | { |
| 7973 | DBUG_ASSERT(info->state == start_alter_state::ROLLBACK_ALTER); |
| 7974 | |
| 7975 | /* |
| 7976 | SA may end up in the rollback state through FTWRL that breaks |
| 7977 | SA's waiting for a master decision. |
| 7978 | Then it completes "officially", and `direct_commit_alter` true status |
| 7979 | will affect the future of CA to re-execute the whole query. |
| 7980 | */ |
| 7981 | info->state= start_alter_state::COMPLETED; |
| 7982 | if (info->direct_commit_alter) |
| 7983 | mysql_cond_broadcast(&info->start_alter_cond); |
| 7984 | mysql_mutex_unlock(&mi->start_alter_lock); |
| 7985 | |
| 7986 | return true; // not really an error to be handled by caller specifically |
| 7987 | } |
| 7988 | mysql_mutex_unlock(&mi->start_alter_lock); |
| 7989 | /* |
| 7990 | We have to call wait for master here because in main calculation |
| 7991 | we can error out before calling wait for master |
| 7992 | (for example if copy_data_between_tables fails) |
| 7993 | */ |
| 7994 | if (info->state == start_alter_state::REGISTERED) |
| 7995 | wait_for_master(thd); |
| 7996 | if(process_master_state(thd, 1, start_alter_id, if_exists)) |
| 7997 | return true; |
| 7998 | } |
| 7999 | else |
| 8000 | #endif |
| 8001 | if (partial_alter) // Write only if SA written |
| 8002 | { |
| 8003 | // Send the rollback message |
| 8004 | Write_log_with_flags wlwf(thd, Gtid_log_event::FL_ROLLBACK_ALTER_E1); |
| 8005 | if(write_bin_log_with_if_exists(thd, false, false, if_exists, false)) |
| 8006 | return true; |
| 8007 | partial_alter= false; |
| 8008 | } |
no test coverage detected