[SERVER-66286] DurableViewCatalog to convert from StringData to DatabaseName Created: 06/May/22  Updated: 29/Oct/23  Resolved: 28/Jun/22

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

Type: Task Priority: Major - P3
Reporter: Hugh Tong (Inactive) Assignee: Fernando Lisboa (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-66355 Pass dbName to validateViewDefinition... Closed
Backwards Compatibility: Fully Compatible
Sprint: Server Serverless 2022-06-27, Server Serverless 2022-07-11
Participants:

 Description   

Description of bug blocking this work:
We are in the process of converting some functions that accept StringData as a parameter for a database name to accept DatabaseName objects instead.  While converting the lone validateViewDefinitionBSON entry in DurableViewCatalog, we uncovered a separate bug exposed by this correction.

validateViewDefinitionBSON is being called by onExternalChange in the original implementation with the database name toString (which includes the tenantId).  validateViewDefinitionBSON performs a string comparison on the database name being passed in vs. the view name from the BSONObj being passed in as part of its validation, which will fail when comparing a database name without the tenantId against one with the tenantId.  When this happens, DurableViewCatalog::onExternalInsert catches the failure and its caller, OpObserverImpl::onInserts, fails silently and re-routes to DurableViewCatalog::onExternalInsert instead.  This results in following a different code path that calls CollectionCatalog::reloadView(), which does not perform the same checks.  In other words, the call to DurableViewCatalog::onExternalInsert will never succeed.

When applying our changes and passing in the correct database name values, validateViewDefinitionBSON now passes and viewName is locally being created in onExternalInsert, but not being locked prior to calling CollectionCatalog::createView(), where an invariant checks that viewName is being locked, causing the failure in the correct code path.

TODO in this ticket:
Change the dbName parameter in validateViewDefinitionBSON to take a DatabaseName obj.



 Comments   
Comment by Githook User [ 27/Jun/22 ]

Author:

{'name': 'Fernando Lisboa', 'email': 'fernando.lisboa@mongodb.com', 'username': 'fernandolis10'}

Message: SERVER-66286 DurableViewCatalog to convert from StringData to DatabaseName
Branch: master
https://github.com/mongodb/mongo/commit/5fb558f05ae5fd38a77af927aac439f28af71da2

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