Skip to content
Permalink
Browse files
Zero gap for HA strategies rebalancer
Let's not loose queries because of not so good idea from the past about
pinging dead hosts with real queries.
It closes #927
  • Loading branch information
klirichek committed Jun 25, 2019
1 parent 58dcbb7 commit a02aae05a3fa3d1caf2821f43c7e237b6de76336
Showing with 6 additions and 14 deletions.
  1. +6 −5 src/gtests_functions.cpp
  2. +0 −9 src/sphinxutils.cpp
@@ -1317,7 +1317,8 @@ static void TestRebalance_fn ( tstcase * pData, int iLen, int iStride )

for ( int j = 0; j<iStride; ++j )
{
ASSERT_NEAR ( dWeights[j], pData[i * iStride + j].wnew, 0.01);
ASSERT_NEAR ( dWeights[j], pData[i * iStride + j].wnew, 0.01)
<< " \n----dWeights[" << j << "]=" << dWeights[j] << " vs " << pData[i * iStride + j].wnew;
}
}
}
@@ -1342,14 +1343,14 @@ TEST ( functions, Rebalance )
{08.5008f, 412733, 32.9526f}, {91.4977f, 202851, 67.0474f} };
TestRebalance_fn ( dData1, sizeof(dData1) / sizeof( tstcase), 2 );

tstcase dData2[] = { { 0.000000f, 0, 10.00000f }, { 00.0015f, 18469, 90.0000f } };
tstcase dData2[] = { { 0.000000f, 0, 0.00000f }, { 00.0015f, 18469, 100.0000f } };
TestRebalance_fn ( dData2, sizeof(dData2) / sizeof( tstcase), 2 );

tstcase dData3[] = { { 0.000000f, 0, 3.3333f }, { 0.0015f, 0, 3.3333f }
, { 0.0031f, 0, 3.3333f }, { 0.0046f, 18469, 90.0000f } };
tstcase dData3[] = { { 0.000000f, 0, 0.00000f }, { 0.0015f, 0, 0.00000f }
, { 0.0031f, 0, 0.00000f }, { 0.0046f, 18469, 100.0000f } };
TestRebalance_fn ( dData3, sizeof ( dData3 ) / sizeof ( tstcase ), 4 );

tstcase dData4[] = { { 0.000000f, 7100, 65.0088f }, { 0.0015f, 0, 10.0f }, { 0.0031f, 18469, 24.9912f } };
tstcase dData4[] = { { 0.000000f, 7100, 72.2320f }, { 0.0015f, 0, 0.0f }, { 0.0031f, 18469, 27.7679f } };
TestRebalance_fn ( dData4, sizeof ( dData4 ) / sizeof ( tstcase ), 3 );
}

@@ -3593,9 +3593,6 @@ bool CSphDynamicLibrary::LoadSymbols ( const char **, void ***, int ) { return f
// calculate new weights as inverse freqs of timers, giving also small probability to bad timers.
void RebalanceWeights ( const CSphFixedVector<int64_t> & dTimers, CSphFixedVector<float>& dWeights )
{
// in case of mirror without response still set small probability to it
const float fEmptiesPercent = 10.0f;

assert ( dTimers.GetLength () );
float fSum = 0.0;
int iAlive = 0;
@@ -3617,13 +3614,7 @@ void RebalanceWeights ( const CSphFixedVector<int64_t> & dTimers, CSphFixedVecto

// if one or more bad (empty) timers provided, give fEmptiesPercent frac to all of them,
// and also assume fEmptiesPercent/num_of_deads fraq per each of them.
int iEmpties = dTimers.GetLength () - iAlive;
float fEmptyPercent = 0.0f;
if ( iEmpties )
{
fSum /= (1.0f-fEmptiesPercent*0.01f);
fEmptyPercent = fEmptiesPercent/iEmpties;
}

// balance weights
float fCheck = 0;

0 comments on commit a02aae0

Please sign in to comment.