@@ -437,9 +437,9 @@ Status SyncMasterDB::CommitAppLog(const LogOffset& master_committed_id){
437437 return coordinator_.CommitAppLog (master_committed_id);
438438}
439439Status SyncMasterDB::AppendCandidateBinlog (const std::string& ip, int port, const LogOffset& offset) {
440- std::shared_ptr<SlaveNode> slave_ptr = GetSlaveNode (ip, port);
440+ std::shared_ptr<SlaveNode> slave_ptr = GetSlaveNode (ip, port);
441441 if (!slave_ptr) {
442- return Status::NotFound (" ip " + ip + " port " + std::to_string (port));
442+ return Status::NotFound (" ip " + ip + " port " + std::to_string (port));
443443 }
444444
445445 {
@@ -452,23 +452,23 @@ Status SyncMasterDB::AppendCandidateBinlog(const std::string& ip, int port, cons
452452 if (slave_ptr->slave_state == KCandidate){
453453 LOG (INFO)<<" PacificA first binlog slave_state is Candidate" ;
454454 }
455- slave_ptr->sent_offset = offset;
455+ slave_ptr->sent_offset = offset;
456456 slave_ptr->acked_offset = offset;
457457 slave_ptr->target_offset =GetPreparedId ();
458458 Status s = slave_ptr->InitBinlogFileReader (Logger (), offset.b_offset );
459459 if (!s.ok ()) {
460460 return Status::Corruption (" Init binlog file reader failed" + s.ToString ()); // 如果初始化失败,返回错误状态
461461 }
462- g_pika_rm->DropItemInOneWriteQueue (ip, port, slave_ptr->DBName ());
463- slave_ptr->b_state = kReadFromFile ;
462+ g_pika_rm->DropItemInOneWriteQueue (ip, port, slave_ptr->DBName ());
463+ slave_ptr->b_state = kReadFromFile ;
464464 }
465465
466466 Status s = coordinator_.SendBinlog (slave_ptr, slave_ptr->DBName ());
467467 if (!s.ok ()) {
468- return s;
468+ return s;
469469 }
470470
471- return Status::OK ();
471+ return Status::OK ();
472472}
473473
474474Status SyncMasterDB::ConsensusProposeLog (const std::shared_ptr<Cmd>& cmd_ptr) {
@@ -489,9 +489,10 @@ Status SyncMasterDB::ConsensusProposeLog(const std::shared_ptr<Cmd>& cmd_ptr) {
489489 while (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now () - start).count () < 10 ) {
490490 // Check if consensus has been achieved for the given log offset
491491 if (checkFinished (offset)) {
492- return Status::OK ();
492+ return Status::OK ();
493493 }
494- std::this_thread::sleep_for (std::chrono::milliseconds (50 ));
494+ // TODO: 这里暂时注掉了sleep等待,50ms耗时过长,影响写入链路,后期需要改成条件变量唤醒方式
495+ // std::this_thread::sleep_for(std::chrono::milliseconds(50));
495496 }
496497
497498 return Status::Timeout (" No consistency achieved within 10 seconds" );
0 commit comments