| 65 | } |
| 66 | |
| 67 | int MasterMonitor::GetGlobalMySQLMaxGTIDList(const Option *option, const vector<string> &iplist, |
| 68 | vector<string> *gtid_list) { |
| 69 | map<string, vector<size_t> > gtid_res; |
| 70 | |
| 71 | for (auto ip : iplist) { |
| 72 | vector < string > tmp_gtid_list; |
| 73 | int ret = MonitorComm::GetMySQLMaxGTIDList(option, "gtid_executed", &tmp_gtid_list, ip); |
| 74 | if (ret) { |
| 75 | ColorLogError("%s get from ip %s fail", __func__, ip.c_str()); |
| 76 | if (ret == GTID_FAIL && ip == option->GetBinLogSvrConfig()->GetEngineIP()) { |
| 77 | STATISTICS(MySqlGTIDBroken()); |
| 78 | assert(ret == OK); |
| 79 | } |
| 80 | return ret; |
| 81 | } |
| 82 | for (auto gtid : tmp_gtid_list) { |
| 83 | pair < string, size_t > parse_list = GtidHandler::ParseGTID(gtid); |
| 84 | gtid_res[parse_list.first].push_back(parse_list.second); |
| 85 | LogVerbose("%s get gtid %s-%u from ip %s", __func__, parse_list.first.c_str(), parse_list.second, |
| 86 | ip.c_str()); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | for (auto >id_check : gtid_res) { |
| 91 | const vector<size_t> &list = gtid_check.second; |
| 92 | if (list.size() != iplist.size()) { |
| 93 | continue; |
| 94 | } |
| 95 | |
| 96 | size_t max_gtid = (size_t) - 1; |
| 97 | for (auto gtid : list) { |
| 98 | max_gtid = std::min(max_gtid, gtid); |
| 99 | } |
| 100 | gtid_list->push_back(GtidHandler::GenGTID(gtid_check.first, max_gtid)); |
| 101 | } |
| 102 | |
| 103 | return OK; |
| 104 | } |
| 105 | |
| 106 | bool MasterMonitor::IsGTIDCompleted(const vector<string> &excute_gtid_list, const string &max_gtid) { |
| 107 | pair < string, size_t > max_gtid_pair = GtidHandler::ParseGTID(max_gtid); |
nothing calls this directly
no test coverage detected