[SERVER-72094] FindCmd checks the bool value of an optional incorrectly Created: 13/Dec/22  Updated: 29/Oct/23  Resolved: 27/Jan/23

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

Type: Bug Priority: Major - P3
Reporter: Matthew Saltz (Inactive) Assignee: Adi Agrawal
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2023-02-06
Participants:

 Description   

The comment here:

            // Set the namespace if a collection was found, as opposed to nothing or a view.
            if (ctx) {
                query_request_helper::refreshNSS(ctx->getNss(), findCommand.get());
            }

make it seem like refreshNss should only be evaluated if the collection exists in ctx, which is of type boost::optional<AutoGetCollectionForReadCommandMaybeLockFree>. But it's actually only checking whether the optional is populated. But the optional is always populated so refreshNss always runs.

It should probably be if (*ctx) or the code should be rewritten to not use an optional, but that might be difficult since we manually reset the optional later on.



 Comments   
Comment by Githook User [ 27/Jan/23 ]

Author:

{'name': 'Adityavardhan Agrawal', 'email': 'aa729@cornell.edu', 'username': 'Adityav369'}

Message: SERVER-72094 fix findCmd checks the bool value of an optional incorrectly
Branch: master
https://github.com/mongodb/mongo/commit/893833c073e0b507ba834fe97f544e27d88751c6

Comment by Steve Tarzia [ 24/Jan/23 ]

It could also be that the comment is incorrect.

Generated at Thu Feb 08 06:20:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.