Skip to content

Commit

Permalink
bug fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
lynncui00 committed Aug 8, 2016
1 parent 6e1f2dd commit cc27d7e
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 93 deletions.
4 changes: 2 additions & 2 deletions makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ endif

.PHONY:install
install:
prefix_dir=`readlink $(PREFIX) -m`;\
@prefix_dir=`readlink $(PREFIX) -m`;\
src_dir=`readlink $(SRC_BASE_PATH) -m`;\
if ([ "$$prefix_dir" != "$$src_dir" ]); then \
echo cp $(PHX_LIB_PATH) $(PREFIX)/include -rf;\
cp $(PHXPAXOS_INCLUDE_PATH) $(PREFIX)/include -rf;\
fi
echo INSTALL to $(PREFIX)/lib;
mkdir $(PREFIX)/lib -p;\
@mkdir $(PREFIX)/lib -p;\
rm $(PREFIX)/lib/* -rf;\
cp $(PHX_EXTLIB_PATH)/* $(PREFIX)/lib/ -rf;

Expand Down
6 changes: 3 additions & 3 deletions src/algorithm/checkpoint_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const bool CheckpointSender :: IsEnd() const

void CheckpointSender :: run()
{
m_llAbsLastAckTime = Time::GetTimestampMS();
m_llAbsLastAckTime = Time::GetSteadyClockMS();

//pause checkpoint replayer
bool bNeedContinue = false;
Expand Down Expand Up @@ -357,14 +357,14 @@ void CheckpointSender :: Ack(const nodeid_t iSendNodeID, const uint64_t llUUID,
}

m_llAckSequence++;
m_llAbsLastAckTime = Time::GetTimestampMS();
m_llAbsLastAckTime = Time::GetSteadyClockMS();
}

const bool CheckpointSender :: CheckAck(const uint64_t llSendSequence)
{
while (llSendSequence > m_llAckSequence + Checkpoint_ACK_LEAD)
{
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
uint64_t llPassTime = llNowTime > m_llAbsLastAckTime ? llNowTime - m_llAbsLastAckTime : 0;

if (m_bIsEnd)
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/committer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int Committer :: NewValueGetIDNoRetry(const std::string & sValue, uint64_t & llI
if (m_iTimeoutMs > 0)
{
iLeftTimeoutMs = m_iTimeoutMs > iLockUseTimeMs ? m_iTimeoutMs - iLockUseTimeMs : 0;
if (iLeftTimeoutMs < 100)
if (iLeftTimeoutMs < 200)
{
PLGErr("Get lock ok, but lockusetime %dms too long, lefttimeout %dms", iLockUseTimeMs, iLeftTimeoutMs);

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/ioloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool IOLoop :: AddTimer(const int iTimeout, const int iType, uint32_t & iTimerID
return true;
}

uint64_t llAbsTime = Time::GetTimestampMS() + iTimeout;
uint64_t llAbsTime = Time::GetSteadyClockMS() + iTimeout;
m_oTimer.AddTimerWithType(llAbsTime, iType, iTimerID);

m_mapTimerIDExist[iTimerID] = true;
Expand Down
10 changes: 5 additions & 5 deletions src/algorithm/learner_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void LearnerSender :: run()

void LearnerSender :: ReleshSending()
{
m_llAbsLastSendTime = Time::GetTimestampMS();
m_llAbsLastSendTime = Time::GetSteadyClockMS();
}

const bool LearnerSender :: IsIMSending()
Expand All @@ -80,7 +80,7 @@ const bool LearnerSender :: IsIMSending()
return false;
}

uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
uint64_t llPassTime = llNowTime > m_llAbsLastSendTime ? llNowTime - m_llAbsLastSendTime : 0;

if ((int)llPassTime >= LearnerSender_PREPARE_TIMEOUT)
Expand All @@ -95,7 +95,7 @@ const bool LearnerSender :: CheckAck(const uint64_t llSendInstanceID)
{
while (llSendInstanceID > m_llAckInstanceID + LearnerSender_ACK_LEAD)
{
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
uint64_t llPassTime = llNowTime > m_llAbsLastAckTime ? llNowTime - m_llAbsLastAckTime : 0;

if ((int)llPassTime >= LearnerSender_ACK_TIMEOUT)
Expand Down Expand Up @@ -126,7 +126,7 @@ const bool LearnerSender :: Prepare(const uint64_t llBeginInstanceID, const node
bPrepareRet = true;

m_bIsIMSending = true;
m_llAbsLastSendTime = m_llAbsLastAckTime = Time::GetTimestampMS();
m_llAbsLastSendTime = m_llAbsLastAckTime = Time::GetSteadyClockMS();
m_llBeginInstanceID = m_llAckInstanceID = llBeginInstanceID;
m_iSendToNodeID = iSendToNodeID;
}
Expand Down Expand Up @@ -169,7 +169,7 @@ void LearnerSender :: Ack(const uint64_t llAckInstanceID, const nodeid_t iFromNo
if (llAckInstanceID > m_llAckInstanceID)
{
m_llAckInstanceID = llAckInstanceID;
m_llAbsLastAckTime = Time::GetTimestampMS();
m_llAbsLastAckTime = Time::GetSteadyClockMS();
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/algorithm/proposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ int Proposer :: NewValue(const std::string & sValue)
{
BP->GetProposerBP()->NewProposal(sValue);

m_oProposerState.SetValue(sValue);
if (m_oProposerState.GetValue().size() == 0)
{
m_oProposerState.SetValue(sValue);
}

m_iLastPrepareTimeoutMs = START_PREPARE_TIMEOUTMS;
m_iLastAcceptTimeoutMs = START_ACCEPT_TIMEOUTMS;
Expand Down
6 changes: 3 additions & 3 deletions src/benchmark/bench_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void RandValue(const int iSize, string & sValue)
}
}

const uint64_t GetTimestampMS()
const uint64_t GetSteadyClockMS()
{
uint64_t llNow;
struct timeval tv;
Expand Down Expand Up @@ -100,7 +100,7 @@ int main(int argc, char ** argv)
WriteOptions wp;
wp.bSync = true;

uint64_t llBeginTimeMs = GetTimestampMS();
uint64_t llBeginTimeMs = GetSteadyClockMS();
for (int i = 0; i < wc; i++)
{
AcceptorStateData oState;
Expand Down Expand Up @@ -128,7 +128,7 @@ int main(int argc, char ** argv)
llInstanceID++;
}

uint64_t llEndTimeMs = GetTimestampMS();
uint64_t llEndTimeMs = GetSteadyClockMS();
int iRunTimeMs = llEndTimeMs - llBeginTimeMs;
int qps = (uint64_t)wc * 1000 / iRunTimeMs;

Expand Down
10 changes: 5 additions & 5 deletions src/benchmark/bench_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int parse_ipport_list(const char * pcStr, NodeInfoList & vecNodeInfoList)
return 0;
}

const uint64_t GetTimestampMS()
const uint64_t GetSteadyClockMS()
{
uint64_t llNow;
struct timeval tv;
Expand Down Expand Up @@ -143,7 +143,7 @@ class BenchClient : public phxpaxos::Thread

void Bench_SmallData(BenchServer & oBenchServer)
{
uint64_t llBeginTimeMs = GetTimestampMS();
uint64_t llBeginTimeMs = GetSteadyClockMS();

const int iWriteCount = 1000;
const int iConcurrentCount = 100;
Expand All @@ -162,7 +162,7 @@ void Bench_SmallData(BenchServer & oBenchServer)
delete vecBenchClient[i];
}

uint64_t llEndTimeMs = GetTimestampMS();
uint64_t llEndTimeMs = GetSteadyClockMS();
int iRunTimeMs = llEndTimeMs - llBeginTimeMs;
int qps = (uint64_t)iWriteCount * iConcurrentCount * 1000 / iRunTimeMs;

Expand All @@ -171,7 +171,7 @@ void Bench_SmallData(BenchServer & oBenchServer)

void Bench_LargeData(BenchServer & oBenchServer)
{
uint64_t llBeginTimeMs = GetTimestampMS();
uint64_t llBeginTimeMs = GetSteadyClockMS();

const int iWriteCount = 100;
const int iConcurrentCount = 100;
Expand All @@ -190,7 +190,7 @@ void Bench_LargeData(BenchServer & oBenchServer)
delete vecBenchClient[i];
}

uint64_t llEndTimeMs = GetTimestampMS();
uint64_t llEndTimeMs = GetSteadyClockMS();
int iRunTimeMs = llEndTimeMs - llBeginTimeMs;
int qps = (uint64_t)iWriteCount * iConcurrentCount * 1000 / iRunTimeMs;

Expand Down
6 changes: 3 additions & 3 deletions src/benchmark/fsync_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void RandValue(const int iSize, string & sValue)
}
}

const uint64_t GetTimestampMS()
const uint64_t GetSteadyClockMS()
{
uint64_t llNow;
struct timeval tv;
Expand Down Expand Up @@ -91,7 +91,7 @@ void benchfsync(const int iValueSize, const int iWriteCount)

lseek(fd, 0, SEEK_SET);

uint64_t llBeginTimeMs = GetTimestampMS();
uint64_t llBeginTimeMs = GetSteadyClockMS();
for (int i = 0; i < iWriteCount; i++)
{
int len = write(fd, sValue.data(), sValue.size());
Expand All @@ -104,7 +104,7 @@ void benchfsync(const int iValueSize, const int iWriteCount)
fdatasync(fd);
}

uint64_t llEndTimeMs = GetTimestampMS();
uint64_t llEndTimeMs = GetSteadyClockMS();
int iRunTimeMs = llEndTimeMs - llBeginTimeMs;
int qps = (uint64_t)iWriteCount * 1000 / iRunTimeMs;

Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/cp_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ int CheckpointMgr :: PrepareForAskforCheckpoint(const nodeid_t iSendNodeID)

if (m_llLastAskforCheckpointTime == 0)
{
m_llLastAskforCheckpointTime = Time::GetTimestampMS();
m_llLastAskforCheckpointTime = Time::GetSteadyClockMS();
}

uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
if (llNowTime > m_llLastAskforCheckpointTime + 60000)
{
PLGImp("no majority reply, just ask for checkpoint");
Expand Down
2 changes: 1 addition & 1 deletion src/comm/inside_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const int InsideOptions :: GetStartAcceptTimeoutMs()
}
else
{
return 2000;
return 1000;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/communicate/tcp/event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool EventLoop :: AddTimer(const Event * poEvent, const int iTimeout, const int
m_mapEvent[poEvent->GetSocketFd()] = tCtx;
}

uint64_t llAbsTime = Time::GetTimestampMS() + iTimeout;
uint64_t llAbsTime = Time::GetSteadyClockMS() + iTimeout;
m_oTimer.AddTimerWithType(llAbsTime, iType, iTimerID);

m_mapTimerID2FD[iTimerID] = poEvent->GetSocketFd();
Expand Down
10 changes: 5 additions & 5 deletions src/communicate/tcp/message_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MessageEvent :: MessageEvent(

m_iReconnectTimeoutID = 0;

m_llLastActiveTime = Time::GetTimestampMS();
m_llLastActiveTime = Time::GetSteadyClockMS();
m_sHost = oAddr.getHost();

m_iQueueMemSize = 0;
Expand Down Expand Up @@ -81,7 +81,7 @@ const std::string & MessageEvent :: GetSocketHost()

const bool MessageEvent :: IsActive()
{
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
if (llNowTime > m_llLastActiveTime
&& ((int)(llNowTime - m_llLastActiveTime) > CONNECTTION_NONACTIVE_TIMEOUT))
{
Expand All @@ -93,7 +93,7 @@ const bool MessageEvent :: IsActive()

int MessageEvent :: AddMessage(const std::string & sMessage)
{
m_llLastActiveTime = Time::GetTimestampMS();
m_llLastActiveTime = Time::GetSteadyClockMS();

m_oMutex.lock();

Expand All @@ -114,7 +114,7 @@ int MessageEvent :: AddMessage(const std::string & sMessage)
}

QueueData tData;
tData.llEnqueueAbsTime = Time::GetTimestampMS();
tData.llEnqueueAbsTime = Time::GetSteadyClockMS();
tData.psValue = new string(sMessage);
m_oInQueue.push(tData);

Expand Down Expand Up @@ -326,7 +326,7 @@ int MessageEvent :: DoOnWrite()
m_oMutex.unlock();

std::string * poMessage = tData.psValue;
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();
if (llNowTime > tData.llEnqueueAbsTime
&& (((int)(llNowTime - tData.llEnqueueAbsTime)) > TCP_OUTQUEUE_DROP_TIMEMS))
{
Expand Down
8 changes: 4 additions & 4 deletions src/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ void Config :: AddTmpNodeOnlyForLearn(const nodeid_t iTmpNodeID)
return;
}

m_mapTmpNodeOnlyForLearn[iTmpNodeID] = Time::GetTimestampMS() + TmpNodeTimeout;
m_mapTmpNodeOnlyForLearn[iTmpNodeID] = Time::GetSteadyClockMS() + TmpNodeTimeout;
}

const std::map<nodeid_t, uint64_t> & Config :: GetTmpNodeMap()
{
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();

for (auto it = m_mapTmpNodeOnlyForLearn.begin(); it != end(m_mapTmpNodeOnlyForLearn);)
{
Expand All @@ -224,12 +224,12 @@ const std::map<nodeid_t, uint64_t> & Config :: GetTmpNodeMap()
void Config :: AddFollowerNode(const nodeid_t iMyFollowerNodeID)
{
static int iFollowerTimeout = ASKFORLEARN_NOOP_INTERVAL * 3;
m_mapMyFollower[iMyFollowerNodeID] = Time::GetTimestampMS() + iFollowerTimeout;
m_mapMyFollower[iMyFollowerNodeID] = Time::GetSteadyClockMS() + iFollowerTimeout;
}

const std::map<nodeid_t, uint64_t> & Config :: GetMyFollowerMap()
{
uint64_t llNowTime = Time::GetTimestampMS();
uint64_t llNowTime = Time::GetSteadyClockMS();

for (auto it = m_mapMyFollower.begin(); it != end(m_mapMyFollower);)
{
Expand Down
6 changes: 3 additions & 3 deletions src/master/master_damon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void MasterDamon :: run()

int iLeaseTime = m_iLeaseTime;

uint64_t llBeginTime = Time::GetTimestampMS();
uint64_t llBeginTime = Time::GetSteadyClockMS();

TryBeMaster(iLeaseTime);

Expand All @@ -104,7 +104,7 @@ void MasterDamon :: run()
PLG1Imp("Need drop master, this round wait time %dms", iConitnueLeaseTimeout);
}

uint64_t llEndTime = Time::GetTimestampMS();
uint64_t llEndTime = Time::GetSteadyClockMS();
int iRunTime = llEndTime > llBeginTime ? llEndTime - llBeginTime : 0;
int iNeedSleepTime = iConitnueLeaseTimeout > iRunTime ? iConitnueLeaseTimeout - iRunTime : 0;

Expand Down Expand Up @@ -143,7 +143,7 @@ void MasterDamon :: TryBeMaster(const int iLeaseTime)

const int iMasterLeaseTimeout = iLeaseTime - 100;

uint64_t llAbsMasterTimeout = Time::GetTimestampMS() + iMasterLeaseTimeout;
uint64_t llAbsMasterTimeout = Time::GetSteadyClockMS() + iMasterLeaseTimeout;
uint64_t llCommitInstanceID = 0;

SMCtx oCtx;
Expand Down
10 changes: 5 additions & 5 deletions src/master/master_sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int MasterStateMachine :: Init()
else
{
m_iMasterNodeID = oVariables.masternodeid();
m_llAbsExpireTime = Time::GetTimestampMS() + oVariables.leasetime();
m_llAbsExpireTime = Time::GetSteadyClockMS() + oVariables.leasetime();
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ int MasterStateMachine :: LearnMaster(
{
//other be master
//use new start timeout
m_llAbsExpireTime = Time::GetTimestampMS() + oMasterOper.timeout();
m_llAbsExpireTime = Time::GetSteadyClockMS() + oMasterOper.timeout();

PLG1Head("Ohter be master, absexpiretime %lu", m_llAbsExpireTime);
}
Expand All @@ -148,7 +148,7 @@ void MasterStateMachine :: SafeGetMaster(nodeid_t & iMasterNodeID, uint64_t & ll
{
ScopedLock<Mutex> oLockGuard(m_oMutex);

if (Time::GetTimestampMS() >= m_llAbsExpireTime)
if (Time::GetSteadyClockMS() >= m_llAbsExpireTime)
{
iMasterNodeID = nullnode;
}
Expand All @@ -162,7 +162,7 @@ void MasterStateMachine :: SafeGetMaster(nodeid_t & iMasterNodeID, uint64_t & ll

const nodeid_t MasterStateMachine :: GetMaster() const
{
if (Time::GetTimestampMS() >= m_llAbsExpireTime)
if (Time::GetSteadyClockMS() >= m_llAbsExpireTime)
{
return nullnode;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ int MasterStateMachine :: UpdateByCheckpoint(const std::string & sCPBuffer, bool
else
{
m_iMasterNodeID = oVariables.masternodeid();
m_llAbsExpireTime = Time::GetTimestampMS() + oVariables.leasetime();
m_llAbsExpireTime = Time::GetSteadyClockMS() + oVariables.leasetime();
}

return 0;
Expand Down
Loading

0 comments on commit cc27d7e

Please sign in to comment.