MCPcopy Create free account
hub / github.com/Tencent/phxsql / CountCheckSum

Method CountCheckSum

phxbinlogsvr/core/repl/replication_transfer.cpp:125–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void ReplicationTransfer::CountCheckSum(const vector<string> &event_list, const string &max_gtid) {
126 LogVerbose("%s count check sum %llu, event size %zu", __func__, checksum_, event_list.size());
127 if (checksum_ == 0) {
128 EventDataInfo info;
129 event_manager_->GetGTIDInfo(max_gtid, &info);
130 checksum_ = info.checksum();
131 LogVerbose("%s get data check sum %llu for init", __func__, checksum_);
132 } else {
133 vector < size_t > checksum_for_log;
134 checksum_for_log.push_back(checksum_);
135 size_t datasize = 0;
136 size_t header_size = GtidHandler::GetEventHeaderSize();
137 for (size_t i = 0; i < event_list.size(); ++i) {
138 checksum_ = Utils::GetCheckSum(checksum_, event_list[i].c_str() + header_size,
139 event_list[i].size() - header_size);
140 datasize += event_list[i].size() - header_size;
141 checksum_for_log.push_back(checksum_);
142 }
143
144 EventDataInfo info;
145 int ret = event_manager_->GetGTIDInfo(max_gtid, &info);
146 if (ret) {
147 ColorLogError("%s get gtid data %s info fail", __func__, max_gtid.c_str());
148 assert(ret == 0);
149 return;
150 }
151
152 ColorLogInfo("%s get data check sum %llu, max gtid %s, gtid check sum %llu data size %zu", __func__, checksum_,
153 max_gtid.c_str(), info.checksum(), datasize);
154
155 if (checksum_ != info.checksum()) {
156 ColorLogError("%s get data check sum %llu, check fail, should be %llu", __func__, checksum_,
157 info.checksum());
158 for (size_t i = 0; i < checksum_for_log.size(); ++i)
159 ColorLogError("%s get check sum %llu", __func__, checksum_for_log[i]);
160 checksum_for_log.push_back(checksum_);
161 STATISTICS(ReplCheckSumFail());
162 assert(checksum_ == info.checksum());
163 }
164 }
165}
166
167}
168

Callers

nothing calls this directly

Calls 4

LogVerboseFunction · 0.85
ColorLogErrorFunction · 0.85
ColorLogInfoFunction · 0.85
GetGTIDInfoMethod · 0.45

Tested by

no test coverage detected