From da171182b7d79d21177d113d2bbaecbca21d8bbc Mon Sep 17 00:00:00 2001 From: mkaruza Date: Wed, 18 Aug 2021 10:13:02 +0200 Subject: MDEV-26223 Galera cluster node consider old server_id value even after modification of server_id [wsrep_gtid_mode=ON] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If cluster is bootstrapped in existing database, we should use provided configuration variables for wsrep_gtid_domain_id and server_id instead of recovered ones. If 'new' combination of wsrep_gtid_domain_id & server_id already existed somewere before in binlog we should continue from last seqno, if combination is new we start from seqno 0. Reviewed-by: Jan Lindström --- sql/wsrep_mysqld.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 972876c24c2..524410152ca 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -804,17 +804,20 @@ void wsrep_init_globals() { wsrep_gtid_server.domain_id= wsrep_gtid_domain_id; wsrep_init_sidno(Wsrep_server_state::instance().connected_gtid().id()); - wsrep_init_gtid(); /* Recover last written wsrep gtid */ + wsrep_init_gtid(); if (wsrep_new_cluster) { - wsrep_server_gtid_t gtid= {wsrep_gtid_server.domain_id, - wsrep_gtid_server.server_id, 0}; - wsrep_get_binlog_gtid_seqno(gtid); - wsrep_gtid_server.seqno(gtid.seqno); + /* Start with provided domain_id & server_id found in configuration */ + wsrep_server_gtid_t new_gtid; + new_gtid.domain_id= wsrep_gtid_domain_id; + new_gtid.server_id= global_system_variables.server_id; + new_gtid.seqno= 0; + /* Try to search for domain_id and server_id combination in binlog if found continue from last seqno */ + wsrep_get_binlog_gtid_seqno(new_gtid); + wsrep_gtid_server.gtid(new_gtid); } wsrep_init_schema(); - if (WSREP_ON) { Wsrep_server_state::instance().initialized(); -- cgit v1.2.1