// called when a GTID has finished being applied, which means // we can remove it from the unappliedGTIDs set void GTIDManager::noteGTIDApplied(const GTID& gtid) { try { boost::unique_lock<boost::mutex> lock(_lock); dassert(GTID::cmp(gtid, _minUnappliedGTID) >= 0); dassert(_unappliedGTIDs.size() > 0); // remove from list of GTIDs _unappliedGTIDs.erase(gtid); // if what we are removing is currently the minumum live GTID // we need to update the minimum live GTID if (GTID::cmp(_minUnappliedGTID, gtid) == 0) { if (_unappliedGTIDs.size() == 0) { _minUnappliedGTID = _lastUnappliedGTID; _minUnappliedGTID.inc(); } else { // get the minumum from _liveGTIDs and set it to _minLiveGTIDs _minUnappliedGTID = *(_unappliedGTIDs.begin()); } } } catch (std::exception &e) { StackStringBuilder ssb; ssb << "exception during noteGTIDApplied, aborting system: " << e.what(); rawOut(ssb.str()); ::abort(); } }
// called when a secondary takes an unapplied GTID it has read in the oplog // and starts to apply it void GTIDManager::noteApplyingGTID(const GTID& gtid) { try { boost::unique_lock<boost::mutex> lock(_lock); dassert(GTID::cmp(gtid, _minUnappliedGTID) >= 0); dassert(GTID::cmp(gtid, _lastUnappliedGTID) > 0); if (_unappliedGTIDs.size() == 0) { _minUnappliedGTID = gtid; } _unappliedGTIDs.insert(gtid); _lastUnappliedGTID = gtid; } catch (std::exception &e) { StackStringBuilder ssb; ssb << "exception during noteApplyingGTID, aborting system: " << e.what(); rawOut(ssb.str()); ::abort(); } }
std::string KVPrefix::toString() const { StackStringBuilder ss; ss << "KVPrefix(" << _value << ")"; return ss.str(); }