[SERVER-57477] stdx::erase_if for stdx::unordered_map Created: 05/Jun/21  Updated: 29/Oct/23  Resolved: 10/Jun/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-51476 Upgrade Abseil to 20210324.1 Closed
Problem/Incident
is caused by SERVER-49965 Add apiVersion metrics to serverStatu... Closed
Related
related to SERVER-57480 Invalid iterator access in api_versio... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0, v4.9
Sprint: Service Arch 2021-06-14
Participants:

 Description   

Introduce a stdx::erase_if that properly handles absl::node_hash_map, which has the peculiar semantics that erase(pos) doesn't return an iterator but also doesn't change traversal order.

Call this erase_if function to repair range based for loops where an element can be erased from the range, and similar code.

This work must be done on its own merits as the codebase is currently suffering UB from these erased iterators, but it also unblocks abseil upgrade SERVER-51476.

Similar to the fix in SERVER-57267.

Abseil at head actually already has absl::erase_if overloads for the containers so we can bring that into stdx later.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 07/Jun/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-57477 stdx::erase_if for stdx::unordered_map

Fix loops that erase elements of the container while iterating over it.

revert api_version_metrics.cpp
Branch: master
https://github.com/mongodb/mongo/commit/f63751ef3dbe5513211e74f0554b42e466ae9711

Comment by Billy Donahue [ 05/Jun/21 ]

Bug in api_version_metrics.cpp introduced by SERVER-49965,
which was released in 4.7.

Comment by Billy Donahue [ 05/Jun/21 ]

Code Review
https://mongodbcr.appspot.com/800010001/

Generated at Thu Feb 08 05:41:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.