Skip to content

Commit

Permalink
[syncd] Bring back TimerWatchdog (sonic-net#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Apr 14, 2021
1 parent badf6ce commit bb341e9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions syncd/Syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "RedisSelectableChannel.h"
#include "ZeroMQSelectableChannel.h"
#include "PerformanceIntervalTimer.h"
#include "TimerWatchdog.h"

#include "sairediscommon.h"

Expand Down Expand Up @@ -4295,6 +4296,14 @@ bool Syncd::isVeryFirstRun()
return firstRun;
}

static void timerWatchdogCallback(
_In_ int64_t span)
{
SWSS_LOG_ENTER();

SWSS_LOG_ERROR("main loop execution exceeded %ld us", span);
}

void Syncd::run()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -4342,6 +4351,10 @@ void Syncd::run()
runMainLoop = false;
}

TimerWatchdog twd(30 * 1000000); // watch for executions over 30 seconds

twd.setCallback(timerWatchdogCallback);

while(runMainLoop)
{
try
Expand All @@ -4350,6 +4363,8 @@ void Syncd::run()

int result = s->select(&sel);

twd.setStartTime();

if (sel == m_restartQuery.get())
{
/*
Expand Down Expand Up @@ -4438,6 +4453,8 @@ void Syncd::run()
{
SWSS_LOG_ERROR("select failed: %d", result);
}

twd.setEndTime();
}
catch(const std::exception &e)
{
Expand All @@ -4454,6 +4471,8 @@ void Syncd::run()

// make sure that if second exception will arise, then we break the loop
m_commandLineOptions->m_disableExitSleep = true;

twd.setEndTime();
}
}

Expand Down

0 comments on commit bb341e9

Please sign in to comment.