mongorestore fails in populated sharded cluster for not dropping admin.tempusers and admin.temproles

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: 100.12.2
    • Component/s: mongorestore
    • None
    • Environment:
      RHEL8, tarballs
    • Tools and Replicator
    • 7

      Problem Statement/Rationale

      If we try to restore a second database into a populated cluster, the restore fails with an IllegalOperation error message

      Steps to Reproduce

      • Set up 2 sharded clusters
      • Create 2 databases in the origin cluster
      • Create roles and users in these databases (not in admin)
      • mongodump a single database with the flag --dumpDbUsersAndRoles
      • mongodump another database with the flag --dumpDbUsersAndRoles
      • mongorestore the first database with the flag --restoreDbUsersAndRoles
      • mongorestore the second database with the flag --restoreDbUsersAndRoles -> error happens here

       

      2025-06-17T18:18:07.927+0000  dropping preexisting temporary collection admin.tempusers
      2025-06-17T18:18:07.928+0000  Failed: restore error: error dropping preexisting temporary collection tempusers: (IllegalOperation) Cannot drop collection in 'admin' database in sharded cluster
      2025-06-17T18:18:07.928+0000  20000 document(s) restored successfully. 0 document(s) failed to restore. 

       

      Expected Results

      Same and different databases can be restored as many times as necessary without errors

      Actual Results

      Error thrown, data for the second database was restored, but users were not

      Additional Notes

      Tests were done today with MongoDB CE v8.0.10 and mongodb-database-tools v100.12.2

      Workaround

      Connect directly to the configuration replica primary node and drop the temp collections:

      db.getSiblingDB("admin").getCollection("tempusers").drop()
      db.getSiblingDB("admin").getCollection("temproles").drop() 

            Assignee:
            Shyam Subramaniyam
            Reporter:
            Pablo Claudino
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: