-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue #13341 ARP entry can be out of sync between kernel and APPL…
…_DB if multiple updates are received from RTNL (#2619) - What I did Fix issue sonic-net/sonic-buildimage#13341 the issue that ARP entry is out of sync between kernel and APPL_DB In AppRestartAssist::insertToMap, in case an entry has been updated more than once with the same value but different from the stored one, keep the state as NEW. Eg. Assume the entry's value that is restored from the warm reboot is V0, the following events received. The first update with value V1 is received and handled by the if (found != appTableCacheMap[tableName].end()) branch, * the state is set to NEW * value is updated to V1 The second update with the same value V1 is received and handled by this branch Originally, the state was set to SAME, which is wrong because V1 is different from the stored value V0 The correct logic should be: set the state to SAME only if the state is not NEW This is a very rare case because most of times, the entry won't be updated multiple times - Why I did it To fix the issue. - How I verified it Mock test is added to cover the case. Signed-off-by: Stephen Sun <stephens@nvidia.com>
- Loading branch information
Showing
3 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#define protected public | ||
#include "orch.h" | ||
#undef protected | ||
#include "ut_helper.h" | ||
//#include "mock_orchagent_main.h" | ||
#include "mock_table.h" | ||
#include "warm_restart.h" | ||
#define private public | ||
#include "warmRestartAssist.h" | ||
#undef private | ||
|
||
#define APP_WRA_TEST_TABLE_NAME "TEST_TABLE" | ||
|
||
namespace warmrestartassist_test | ||
{ | ||
using namespace std; | ||
|
||
shared_ptr<swss::DBConnector> m_app_db = make_shared<swss::DBConnector>("APPL_DB", 0); | ||
shared_ptr<swss::RedisPipeline> m_app_db_pipeline = make_shared<swss::RedisPipeline>(m_app_db.get()); | ||
shared_ptr<swss::ProducerStateTable> m_wra_test_table = make_shared<swss::ProducerStateTable>(m_app_db.get(), APP_WRA_TEST_TABLE_NAME); | ||
|
||
AppRestartAssist *appRestartAssist; | ||
|
||
struct WarmrestartassistTest : public ::testing::Test | ||
{ | ||
WarmrestartassistTest() | ||
{ | ||
appRestartAssist = new AppRestartAssist(m_app_db_pipeline.get(), "testsyncd", "swss", 0); | ||
appRestartAssist->m_warmStartInProgress = true; | ||
appRestartAssist->registerAppTable(APP_WRA_TEST_TABLE_NAME, m_wra_test_table.get()); | ||
} | ||
|
||
void SetUp() override | ||
{ | ||
testing_db::reset(); | ||
|
||
Table testTable = Table(m_app_db.get(), APP_WRA_TEST_TABLE_NAME); | ||
testTable.set("key", | ||
{ | ||
{"field", "value0"}, | ||
}); | ||
} | ||
|
||
void TearDown() override | ||
{ | ||
} | ||
}; | ||
|
||
TEST_F(WarmrestartassistTest, warmRestartAssistTest) | ||
{ | ||
appRestartAssist->readTablesToMap(); | ||
vector<FieldValueTuple> fvVector; | ||
fvVector.emplace_back("field", "value1"); | ||
appRestartAssist->insertToMap(APP_WRA_TEST_TABLE_NAME, "key", fvVector, false); | ||
appRestartAssist->insertToMap(APP_WRA_TEST_TABLE_NAME, "key", fvVector, false); | ||
appRestartAssist->reconcile(); | ||
|
||
fvVector.clear(); | ||
Table testTable = Table(m_app_db.get(), APP_WRA_TEST_TABLE_NAME); | ||
ASSERT_TRUE(testTable.get("key", fvVector)); | ||
ASSERT_EQ(fvField(fvVector[0]), "field"); | ||
ASSERT_EQ(fvValue(fvVector[0]), "value1"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters