MCPcopy Create free account
hub / github.com/Tencent/phxqueue / WriteRestartCheckpoint

Method WriteRestartCheckpoint

phxqueue/lock/cleanthread.cpp:209–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void CleanThread::WriteRestartCheckpoint(const int paxos_group_id, const uint64_t now) {
210 uint64_t now_instance_id{impl_->lock->GetNode()->GetNowInstanceID(paxos_group_id)};
211 uint64_t checkpoint{impl_->lock->GetLockMgr()->checkpoint(paxos_group_id)};
212 uint64_t last_instance_id{impl_->lock->GetLockMgr()->last_instance_id(paxos_group_id)};
213
214 if (last_instance_id == checkpoint && now_instance_id > checkpoint + 1 &&
215 phxpaxos::NoCheckpoint != now_instance_id) {
216 // now_instance_id may be not chosen, should write now_instance_id - 1
217 comm::RetCode ret{impl_->lock->GetLockMgr()->
218 WriteRestartCheckpoint(paxos_group_id, now_instance_id - 1)};
219 if (comm::RetCode::RET_OK == ret) {
220 QLInfo("topic_id %d paxos_group_id %d WriteRestartCheckpoint ok checkpoint %llu"
221 " last_instance_id %llu now_instance_id %llu",
222 impl_->lock->GetTopicID(), paxos_group_id,
223 checkpoint, last_instance_id, now_instance_id);
224 } else {
225 QLErr("topic_id %d paxos_group_id %d WriteRestartCheckpoint err %d checkpoint %llu"
226 " last_instance_id %llu now_instance_id %llu",
227 impl_->lock->GetTopicID(), paxos_group_id, ret,
228 checkpoint, last_instance_id, now_instance_id);
229 }
230 } else {
231 QLInfo("topic_id %d paxos_group_id %d WriteRestartCheckpoint skip checkpoint %llu"
232 " last_instance_id %llu now_instance_id %llu",
233 impl_->lock->GetTopicID(), paxos_group_id,
234 checkpoint, last_instance_id, now_instance_id);
235 }
236}
237
238//void CleanThread::DoRun() {
239// if (nullptr == impl_->lock || nullptr == impl_->lock->GetNode()) {

Callers

nothing calls this directly

Calls 5

GetLockMgrMethod · 0.80
GetNodeMethod · 0.45
checkpointMethod · 0.45
last_instance_idMethod · 0.45
GetTopicIDMethod · 0.45

Tested by

no test coverage detected