diff options
author | unknown <knielsen@knielsen-hq.org> | 2013-06-05 14:32:47 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2013-06-05 14:32:47 +0200 |
commit | 5cb486d159e45b9b8dc4d647b2df2492a286cf4d (patch) | |
tree | 85bdb56bae9cad68033b742092012f0961172745 /sql/sql_parse.cc | |
parent | 7ad47ab0e080ca66f8a41de461b036d3bdff25fb (diff) | |
download | mariadb-git-5cb486d159e45b9b8dc4d647b2df2492a286cf4d.tar.gz |
MDEV-26: Global transaction ID.
Fix problems related to reconnect. When we need to reconnect (ie. explict
stop/start of just the IO thread by user, or automatic reconnect due to
loosing network connection with the master), it is a bit complex to correctly
resume at the right point without causing duplicate or missing events in the
relay log. The previous code had multiple problems in this regard.
With this patch, the problem is solved as follows. The IO thread keeps track
(in memory) of which GTID was last queued to the relay log. If it needs to
reconnect, it resumes at that GTID position. It also counts number of events
received within the last, possibly partial, event group, and skips the same
number of events after a reconnect, so that events already enqueued before the
reconnect are not duplicated.
(There is no need to keep any persistent state; whenever we restart slave
threads after both of them being stopped (such as after server restart), we
erase the relay logs and start over from the last GTID applied by SQL thread.
But while the SQL thread is running, this patch is needed to get correct relay
log).
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c6372099600..4625a61f22c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2776,13 +2776,34 @@ end_with_restore_list: { LEX_MASTER_INFO* lex_mi= &thd->lex->mi; Master_info *mi; + int load_error; + + load_error= rpl_load_gtid_slave_state(thd); + mysql_mutex_lock(&LOCK_active_mi); if ((mi= (master_info_index-> get_master_info(&lex_mi->connection_name, MYSQL_ERROR::WARN_LEVEL_ERROR)))) + { + if (load_error) + { + /* + We cannot start a slave using GTID if we cannot load the GTID position + from the mysql.gtid_slave_pos table. But we can allow non-GTID + replication (useful eg. during upgrade). + */ + if (mi->using_gtid != Master_info::USE_GTID_NO) + { + mysql_mutex_unlock(&LOCK_active_mi); + break; + } + else + thd->clear_error(); + } if (!start_slave(thd, mi, 1 /* net report*/)) my_ok(thd); + } mysql_mutex_unlock(&LOCK_active_mi); break; } |