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

Remove AutoGetOrCreateDb

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Execution Team 2021-05-03

      With the introduction of AutoGetDb::ensureDbExists() and AutoGetCollection::ensureDbExists() in SERVER-45955, there is no longer a need for AutoGetOrCreateDb and removing it would simplify the codebase. Going through and directly translating the uses should be trivial, however anywhere we use this pattern:

      AutoGetOrCreateDb autoDb(opCtx, ns.db(), MODE_IX);
      Lock::CollectionLock collLock(opCtx, ns, MODE_IX);
      Database* db = autoDb.getDb();
      

      should be changed into

      AutoGetCollection autoColl(opCtx, ns, MODE_IX);
      Database* db = autoColl.ensureDbExists();
      

      This change leads to implicitly creating the system.views collection hitting this uassert, which we would should investigate whether we can circumvent.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            gregory.noma@mongodb.com Gregory Noma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: