Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-66286

DurableViewCatalog to convert from StringData to DatabaseName

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • Server Serverless 2022-06-27, Server Serverless 2022-07-11

      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.

            Assignee:
            fernando.lisboa@mongodb.com Fernando Lisboa (Inactive)
            Reporter:
            hugh.tong@mongodb.com Hugh Tong (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: