[SERVER-78409] Mongo client fails with Error: attempt to copy-construct an iterator from a singular iterator. Created: 23/Jun/23 Updated: 29/Oct/23 Resolved: 07/Jul/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Adi Zaimi | Assignee: | Adi Zaimi |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Sharding NYC
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
While testing a patch build, this error shows up in one of the tests for evergreen run:
|
| Comments |
| Comment by Githook User [ 06/Jul/23 ] | |||||||||||||
|
Author: {'name': 'Adi Zaimi', 'email': 'adi.zaimi@mongodb.com', 'username': 'adizaimi'}Message: Removing from the list by iterator queryIter resulted in failure because | |||||||||||||
| Comment by Adi Zaimi [ 06/Jul/23 ] | |||||||||||||
|
Created https://jira.mongodb.org/browse/SERVER-78741 to test performance and add any future fixes. | |||||||||||||
| Comment by Adi Zaimi [ 06/Jul/23 ] | |||||||||||||
|
Actually having a reference to an invalid iterator is the issue here, and the only way to not have this situation is to not refer to the iterator which may be invalid. We should simply erase the element by query (using list.find()). This may introduce a bit of a performance concern if the list is really large. The list of connections can not physically be too large, but even so, in future we may want to convert the list into a map. | |||||||||||||
| Comment by Adi Zaimi [ 28/Jun/23 ] | |||||||||||||
|
I think the issue here is that the iterator queryIter has been invalidated and the list container is empty by the time the lambda function is called and calls the copy constructor of the queryIter:
Parameter queryIter to lambda should be either by reference (is that valid if parent queryIter goes out of scope – this is an async call: can queryIter go out of scope?), or we should use move operation. | |||||||||||||
| Comment by Adi Zaimi [ 28/Jun/23 ] | |||||||||||||
|
If I understand this correctly, in the code, line 425 we have inserted an item auto queryIter = _outstandingQueries.insert but that iterator has been invalidated because (in frame 5 of the stack trace above) the list is empty:
| |||||||||||||
| Comment by Adi Zaimi [ 28/Jun/23 ] | |||||||||||||
|
> gdb mongo dump_Replica.xecutor.9471.core
| |||||||||||||
| Comment by Adi Zaimi [ 23/Jun/23 ] | |||||||||||||
|
Another instance of the crash can be found here: https://parsley.mongodb.com/resmoke/4e834bb436eea0eeb16799dc5a24e5f3/test/176b68718792e9ad4d5f30fc4863419e?bookmarks=0,461&shareLine=0 |