Permalink
Browse files

Fix #387 stuck of 'ping' behaviour on change HA agent to usual host

  • Loading branch information...
klirichek committed Aug 13, 2018
1 parent 39c740f commit adaf9772f95772ad6d5297acace6c5cb92b56ad5
Showing with 17 additions and 7 deletions.
  1. +3 −2 src/searchd.cpp
  2. +11 −3 src/searchdha.cpp
  3. +3 −2 src/searchdha.h
@@ -11206,7 +11206,7 @@ void BuildOneAgentStatus ( VectorLike & dStatus, HostDashboard_t* pDash, const c
if ( dStatus.MatchAddVa ( "%s_references", sPrefix ) )
dStatus.Add().SetSprintf ( "%d", (int) pDash->GetRefcount()-1 ); // -1 since we currently also 'use' the agent, reading it's stats
if ( dStatus.MatchAddVa ( "%s_ping", sPrefix ) )
dStatus.Add ().SetSprintf ( "%s", pDash->m_bNeedPing ? "yes" : "no" );
dStatus.Add ().SetSprintf ( "%s", pDash->m_iNeedPing ? "yes" : "no" );
if ( dStatus.MatchAddVa ( "%s_has_perspool", sPrefix ) )
dStatus.Add ().SetSprintf ( "%s", pDash->m_pPersPool ? "yes" : "no" );
if ( dStatus.MatchAddVa ( "%s_need_resolve", sPrefix ) )
@@ -14521,7 +14521,8 @@ static void CheckPing ( int64_t iNow )
g_tDashes.GetActiveDashes ( dDashes );
for ( auto& pDash : dDashes )
{
if ( pDash->m_bNeedPing )
assert ( pDash->m_iNeedPing>=0 );
if ( pDash->m_iNeedPing )
{
CSphScopedRLock tRguard ( pDash->m_dDataLock );
if ( pDash->IsOlder ( iNow ) )
@@ -558,14 +558,22 @@ bool MultiAgentDesc_c::Init ( const CSphVector<AgentDesc_t *> &dHosts,
m_dWeights[i] = fFrac;
}
// require pings for HA agent
if ( IsHA () )
// agents with neeping!=0 will be pinged
m_bNeedPing = IsHA () && !tOpt.m_bBlackhole;
if ( m_bNeedPing )
for ( int i = 0; i<GetLength (); ++i )
m_pData[i].m_pDash->m_bNeedPing = true;
++m_pData[i].m_pDash->m_iNeedPing;
return true;
}
MultiAgentDesc_c::~MultiAgentDesc_c()
{
if ( m_bNeedPing )
for ( int i = 0; i<GetLength (); ++i )
--m_pData[i].m_pDash->m_iNeedPing;
}
const AgentDesc_t &MultiAgentDesc_c::RRAgent ()
{
if ( !IsHA() )
@@ -235,7 +235,7 @@ using HostStatSnapshot_t = uint64_t[eMaxAgentStat + ehMaxStat];
struct HostDashboard_t : public ISphRefcountedMT
{
HostDesc_t m_tHost; // only host info, no indices. Used for ping.
bool m_bNeedPing = false; // we'll ping only HA agents, not everyone
volatile int m_iNeedPing = 0; // we'll ping only HA agents, not everyone
PersistentConnectionsPool_c * m_pPersPool = nullptr; // persistence pool also lives here, one per dashboard
mutable RwLock_t m_dDataLock; // guards everything essential (see thread annotations)
@@ -314,8 +314,9 @@ class MultiAgentDesc_c : public ISphRefcountedMT, public CSphFixedVector<AgentDe
DWORD m_uTimestamp { HostDashboard_t::GetCurSeconds () }; /// timestamp of last weight's actualization
HAStrategies_e m_eStrategy { HA_DEFAULT };
int m_iMultiRetryCount = 0;
bool m_bNeedPing = false; /// ping need to hosts if we're HA and NOT bl.
~MultiAgentDesc_c () final = default;
~MultiAgentDesc_c () final;
public:
MultiAgentDesc_c ()

0 comments on commit adaf977

Please sign in to comment.