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

Method ExecuteForCheckpoint

phxqueue/lock/locksm.cpp:199–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199bool LockSM::ExecuteForCheckpoint(const int paxos_group_id, const uint64_t instance_id,
200 const string &paxos_value) {
201 comm::LockSMBP::GetThreadInstance()->
202 OnExecuteForCheckpoint(impl_->lock->GetTopicID(), paxos_group_id,
203 instance_id, paxos_value);
204
205 if (impl_->lock->GetLockOption()->no_leveldb)
206 return true;
207
208 const uint64_t checkpoint{impl_->lock->GetLockMgr()->checkpoint(paxos_group_id)};
209 bool sync{instance_id - checkpoint >= impl_->lock->GetLockOption()->checkpoint_interval};
210 if (!sync) {
211 const uint64_t now{comm::utils::Time::GetSteadyClockMS()};
212 if (now > last_sync_ms_ + 60000) {
213 sync = true;
214 }
215 }
216 if (sync) {
217 last_sync_ms_ = comm::utils::Time::GetSteadyClockMS();
218
219 comm::LockSMBP::GetThreadInstance()->
220 OnExecuteForCheckpointSync(impl_->lock->GetTopicID(), paxos_group_id,
221 instance_id, paxos_value);
222 } else {
223 comm::LockSMBP::GetThreadInstance()->
224 OnExecuteForCheckpointNoSync(impl_->lock->GetTopicID(), paxos_group_id,
225 instance_id, paxos_value);
226 }
227 QLVerb("topic_id %d paxos_group_id %d instance_id %llu cp %llu sync %d",
228 impl_->lock->GetTopicID(), paxos_group_id, instance_id, checkpoint, sync);
229
230 proto::LockPaxosArgs args;
231 bool succ{args.ParseFromString(paxos_value)};
232 if (!succ) {
233 QLErr("topic_id %d paxos_group_id %d instance_id %llu ParseFromString err",
234 impl_->lock->GetTopicID(), paxos_group_id, instance_id);
235
236 return false;
237 }
238
239 return DoExecute(impl_->lock, LockDb::Type::LEVELDB,
240 paxos_group_id, instance_id, args, sync);
241}
242
243const uint64_t LockSM::GetCheckpointInstanceID(const int paxos_group_id) const {
244 comm::LockSMBP::GetThreadInstance()->

Callers

nothing calls this directly

Calls 8

DoExecuteFunction · 0.85
GetLockOptionMethod · 0.80
GetLockMgrMethod · 0.80
GetTopicIDMethod · 0.45
checkpointMethod · 0.45

Tested by

no test coverage detected