[SERVER-70438] AutoGetCollection can return a valid collection and null database Created: 11/Oct/22  Updated: 29/Oct/23  Resolved: 19/Dec/22

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: Yujin Kang Park Assignee: Yujin Kang Park
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2022-12-12, Execution Team 2022-12-26
Participants:

 Description   

AutoGetCollection first takes AutoGetDb, and later performs a collection lookup in the catalog. 

These opens the possibility for two operations that run concurrently, such that one of them creates the database and the collection, and another takes an AutoGetCollection, to cause an AutoGetCollection to return a valid collection pointer, but a null database pointer. This is something unexpected, as the assumption is that if the collection exists, the database exists.

Do we want to do something about this?

 

Create Other
  •  
AutoGetCollection
  •  
> AutoGetDb (_db = 0x0)
AutoGetCollection  
> AutoGetDb  
> acquire collection locks  
> _coll = lookupCollection  
create database  
create collection  
commit  
  •  
> acquire collection locks
  •  
> _coll = lookupCollection
  •  
if(autoColl) succeeds
  •  
autoColl.getDb() null

 



 Comments   
Comment by Githook User [ 15/Dec/22 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'ykangpark'}

Message: SERVER-70438 Fix AutoGetCollection containing a valid coll reference and an invalid db reference
Branch: master
https://github.com/mongodb/mongo/commit/e5a3eb14ded9ae4c5c85a03fc538a7dbc0533f9b

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