[SERVER-63754] avoid copying NamespaceStringOrUUID vector in OptionsWithSecondaryCollections Created: 16/Feb/22  Updated: 29/Oct/23  Resolved: 17/Jul/23

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

Type: Improvement Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-78460 Complete TODO listed in SERVER-63754 Closed
is related to SERVER-59958 Extend multi-collection locking to th... Closed
is related to SERVER-62006 Support majority read for _mdb_catalog Closed
is related to SERVER-68336 Add version of AutoGetCollection whic... Closed
is related to SERVER-68337 Perform collectionUUID check inside o... Closed
Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Sprint: Execution NAMR Team 2023-07-24
Participants:

 Description   

Currently to provide a list of secondary namespaces to the `AutoGetCollection` RAII types, we pass a copy of the secondary namespaces to OptionsWithSecondaryCollections. This vector of namespaces is not retained by the RAII type after constructing the `AutoGet` object. As proposed in a comment on this ticket, it would be nice to provide a way for the constructor to accept iterators into an existing vector of secondary namespaces rather than have to make a copy of the entire vector.

====== OLD DESCRIPTION ======

In SERVER-59958, we added multi-collection support to the `AutoGetCollectionForRead` helpers, It would be convenient to to have overloads for the constructors to accept a list of namespaces for the primary and secondary collections without having to provide the defaults for other constructor arguments such as viewMode or deadline.



 Comments   
Comment by Githook User [ 17/Jul/23 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-63754 OptionsWithSecondaryCollections accepts iterator range instead of copy to secondary namespaces vector to avoid copying
Branch: master
https://github.com/mongodb/mongo/commit/386bd6da70f44b557fdd0d8021ecdc8764e1f43e

Comment by Githook User [ 16/Jul/23 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-63754 db_raii.cpp helper getConsistentCatalogAndSnapshot() accepts iterator range instead of reference to namespace vector
Branch: master
https://github.com/mongodb/mongo/commit/695a8f5bb6143cbfff8abab1efc64a8d9c78a6b4

Comment by Githook User [ 16/Jul/23 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-63754 db_raii.cpp helper resolveSecondaryNamespacesOrUUIDs() accepts iterator range instead of reference to namespace vector
Branch: master
https://github.com/mongodb/mongo/commit/127a96b93309aa444b146b1c720db8b24cabf569

Comment by Githook User [ 15/Jul/23 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-63754 AutoStatsTracker accepts optional iterator range instead of reference to namespace vector
Branch: master
https://github.com/mongodb/mongo/commit/f27ed00b60e7dc00c66e3034c474cc35b82a1dee

Comment by Githook User [ 15/Jul/23 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-63754 catalog_helper::acquireCollectionLocksInResourceIdOrder() accepts iterators into namespaces vector instead of reference to container
Branch: master
https://github.com/mongodb/mongo/commit/61f8588e26c3ed2f0716437acbc640a82f512e52

Comment by Benety Goh [ 13/Jul/23 ]

Re-opening to consider adopting Dianna's proposal for modifiying the AutoGet constructor to accept iterators into the vector of namespaces.

Comment by Benety Goh [ 12/Jul/23 ]

Part of the reason for closing this ticket as "Gone Away" is due to the introduction of OptionsWithSecondaryCollections in SERVER-68336. The new options class still makes a copy of the vector of namespace/uuid struct.

Comment by Dianna Hohensee (Inactive) [ 01/Mar/22 ]

Spoke with Benety and Henrik. The proposal is the addition of a new constructor that specifically supports this caller pattern to avoid copying the input secondary namespace vector

Suggested constructor:

AutoGet(OpCtx*, PrimaryNs, SecondaryBegin, SecondaryEnd)

Caller pattern:

        AutoGetCollectionForReadCommandMaybeLockFree collLock(
            opCtx,
            systemViewsNamespaces.front(),
            AutoGetCollectionViewMode::kViewsForbidden,
            Date_t::max(),
            AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
            {++systemViewsNamespaces.cbegin(), systemViewsNamespaces.cend()});

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