diff options
author | Sachin <sachinsetia1001@gmail.com> | 2021-01-29 11:59:14 +0000 |
---|---|---|
committer | Andrei <andrei.elkin@mariadb.com> | 2021-11-16 19:38:35 +0200 |
commit | f9f578c7db1924456938a061b3c6287cd09c3963 (patch) | |
tree | 820b9bebd6e9ff52f11d0f3d75eed3f3343fcbf1 /sql/rpl_mi.cc | |
parent | 5566cbadb03856aba9c236b131f544490cd2bee4 (diff) | |
download | mariadb-git-bb-10.8-MENT-662-tmp.tar.gz |
MDEV-662 Lag Free Alter On Slavebb-10.8-MENT-662-tmp
This commit implements two phase binloggable ALTER.
When a new
@@session.binlog_alter_two_phase = YES
ALTER query gets logged in two parts, the START ALTER
and the COMMIT or ROLLBACK ALTER. START Alter is written
in binlog as soon as at its handling necessary locks are
acquired for the table. The timing is such that any
concurrent DML:s that update the same table are either
committed, thus logged into binary log having done work
on the old version of the table, or will be queued for
execution on its new version.
The "COMPLETE" COMMIT or ROLLBACK ALTER are written after
the most of ALTER work is done. When its result is positive
COMMIT ALTER is written, otherwise when there were errors
since START ALTER, ROLLBACK ALTER is written. Replication
of two-phase binloggable ALTER is cross-version safe.
Specifically the OLD slave merely does not recognized the
start alter part, still memorizing its gtid.
Two phase logged ALTER is read from binlog by mysqlbinlog
to produce BINLOG 'string', where 'string' contains base64
encoded Query_log_event containing either the start part of
ALTER, or a completion part. The Query details can be
displayed with `-v` flag, similarly to ROW format events.
Notice, mysqlbinlog output containing parts of two-phase
binloggable ALTER is processable correctly only by
binlog_alter_two_phase server.
Thanks to all people involved into early discussion of the
feature including Kristian Nielsen, those who helped to
design, implement and test: Sergei Golubchik, Andrei Elkin,
Sujatha Sivakumar, Brandon Nesterenko, Alice Sherepa.
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r-- | sql/rpl_mi.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 4fd36891a4b..00ea7743810 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -85,6 +85,14 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg, mysql_mutex_init(key_master_info_data_lock, &data_lock, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_master_info_start_stop_lock, &start_stop_lock, MY_MUTEX_INIT_SLOW); + /* + start_alter_lock will protect individual start_alter_info while + start_alter_list_lock is for list insertion and deletion operations + */ + mysql_mutex_init(key_master_info_start_alter_lock, &start_alter_lock, + MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_master_info_start_alter_list_lock, &start_alter_list_lock, + MY_MUTEX_INIT_FAST); mysql_mutex_setflags(&run_lock, MYF_NO_DEADLOCK_DETECTION); mysql_mutex_setflags(&data_lock, MYF_NO_DEADLOCK_DETECTION); mysql_mutex_init(key_master_info_sleep_lock, &sleep_lock, MY_MUTEX_INIT_FAST); @@ -121,6 +129,8 @@ Master_info::~Master_info() mysql_mutex_destroy(&data_lock); mysql_mutex_destroy(&sleep_lock); mysql_mutex_destroy(&start_stop_lock); + mysql_mutex_destroy(&start_alter_lock); + mysql_mutex_destroy(&start_alter_list_lock); mysql_cond_destroy(&data_cond); mysql_cond_destroy(&start_cond); mysql_cond_destroy(&stop_cond); |