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

[bulk mode] Fix bulk conflict when in case there are both remove and set operations #2071

Merged
merged 3 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ class EntityBulker
return creating_entries.count(entry);
}

bool bulk_entry_pending_removal(const Te& entry) const
{
return removing_entries.find(entry) != removing_entries.end();
}

private:
std::unordered_map< // A map of
Te, // entry ->
Expand Down
6 changes: 5 additions & 1 deletion orchagent/mplsrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,12 @@ bool RouteOrch::addLabelRoute(LabelRouteBulkContext& ctx, const NextHopGroupKey
* in m_syncdLabelRoutes, then we need to update the route with a new next hop
* (group) id. The old next hop (group) is then not used and the reference
* count will decrease by 1.
*
* In case the entry is already pending removal in the bulk, it would be removed
* from m_syncdLabelRoutes during the bulk call. Therefore, such entries need to be
* re-created rather than set attribute.
*/
if (it_route == m_syncdLabelRoutes.at(vrf_id).end())
if (it_route == m_syncdLabelRoutes.at(vrf_id).end() || gLabelRouteBulker.bulk_entry_pending_removal(inseg_entry))
{
vector<sai_attribute_t> inseg_attrs;
if (blackhole)
Expand Down
6 changes: 5 additions & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,8 +1826,12 @@ bool RouteOrch::addRoute(RouteBulkContext& ctx, const NextHopGroupKey &nextHops)
* in m_syncdRoutes, then we need to update the route with a new next hop
* (group) id. The old next hop (group) is then not used and the reference
* count will decrease by 1.
*
* In case the entry is already pending removal in the bulk, it would be removed
* from m_syncdRoutes during the bulk call. Therefore, such entries need to be
* re-created rather than set attribute.
*/
if (it_route == m_syncdRoutes.at(vrf_id).end())
if (it_route == m_syncdRoutes.at(vrf_id).end() || gRouteBulker.bulk_entry_pending_removal(route_entry))
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a unit test for the bulker function

{
if (blackhole)
{
Expand Down