Skip to content

Commit

Permalink
[neighorch] Remove pending DEL operation after SET operation for the …
Browse files Browse the repository at this point in the history
…same key (#1485)

* Remove del operation if set is successfully done in neighorch

* using reverse iterator to travel backwards
  • Loading branch information
shi-su committed Oct 29, 2020
1 parent 8696e93 commit 2265f54
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,31 @@ void NeighOrch::doTask(Consumer &consumer)
if (m_syncdNeighbors.find(neighbor_entry) == m_syncdNeighbors.end() || m_syncdNeighbors[neighbor_entry] != mac_address)
{
if (addNeighbor(neighbor_entry, mac_address))
{
it = consumer.m_toSync.erase(it);
}
else
{
it++;
continue;
}
}
else
{
/* Duplicate entry */
it = consumer.m_toSync.erase(it);
}

/* Remove remaining DEL operation in m_toSync for the same neighbor.
* Since DEL operation is supposed to be executed before SET for the same neighbor
* A remaining DEL after the SET operation means the DEL operation failed previously and should not be executed anymore
*/
auto rit = make_reverse_iterator(it);
while (rit != consumer.m_toSync.rend() && rit->first == key && kfvOp(rit->second) == DEL_COMMAND)
{
consumer.m_toSync.erase(next(rit).base());
SWSS_LOG_NOTICE("Removed pending neighbor DEL operation for %s after SET operation", key.c_str());
}
}
else if (op == DEL_COMMAND)
{
Expand Down

0 comments on commit 2265f54

Please sign in to comment.