Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing race condition for rif counters #1136 (202205 branch) #1202

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions syncd/FlexCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,38 @@ void FlexCounter::removeFlowCounter(
}
}

string FlexCounter::getRifCounterTableKey(string key)
{
SWSS_LOG_ENTER();
return "COUNTERS:" + key;
}

string FlexCounter::getRifRateTableKey(string key)
{
SWSS_LOG_ENTER();
return "RATES:" + key;
}

string FlexCounter::getRifRateInitTableKey(string key)
{
SWSS_LOG_ENTER();
return "RATES:" + key + ":RIF";
}

void FlexCounter::cleanUpRifFromCounterDb(_In_ sai_object_id_t rifId)
{
SWSS_LOG_ENTER();
const auto id = sai_serialize_object_id(rifId);
swss::DBConnector db(m_dbCounters, 0);
string counter_key = getRifCounterTableKey(id);
string rate_key = getRifRateTableKey(id);
string rate_init_key = getRifRateInitTableKey(id);
db.del(counter_key);
db.del(rate_key);
db.del(rate_init_key);
SWSS_LOG_NOTICE("CleanUp oid %s from counter db", id.c_str());
}

void FlexCounter::removeRif(
_In_ sai_object_id_t rifVid)
{
Expand All @@ -1030,6 +1062,7 @@ void FlexCounter::removeRif(
}

m_rifCounterIdsMap.erase(it);
cleanUpRifFromCounterDb(rifVid);

if (m_rifCounterIdsMap.empty())
{
Expand Down
5 changes: 5 additions & 0 deletions syncd/FlexCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace syncd

bool isDiscarded();

std::string getRifCounterTableKey(std::string s);
std::string getRifRateTableKey(std::string s);
std::string getRifRateInitTableKey(std::string s);
void cleanUpRifFromCounterDb(_In_ sai_object_id_t rifId);

private:

void setPollInterval(
Expand Down