Mongorestore not working when roles are added

Hi all,

I’m currently testing the mongodump and mongorestore commands for a MongoDB single installation but I can’t get it working. Everything works fine until I add a new user. If I make a new mongodump and mongorestore I get the following error:

Failed: restore error: error running merge command: (Location40414) BSON field '_mergeAuthzCollections.tempRolesCollection' is missing but a required field

I’m using the docker container docker pull mongo:5.0.2 which uses the following versions:

Ubuntu 20.04.2 LTS
MongoDB 5.0.2
mongodump 100.4.1
mongorestore 100.4.1

This is what I’m doing:

# MongoDB shell
db.test.insert( { item: "card1", qty: 15 } )
db.test.insert( { item: "card2", qty: 30 } )
db.test.insert( { item: "card3", qty: 45 } )
db.test.insert( { item: "card4", qty: 60 } )
db.test.insert( { item: "card5", qty: 75 } )

# bash shell
mongorestore --drop dump

# Until now everything works without any problem so I'm going to add a new user

# MongoDB shell
db.createUser({user: "testUser", pwd: "testpwd", roles: [{role: "userAdminAnyDatabase" , db:"admin"}]})

# bash shell
2021-08-19T09:11:04.033+0000	writing admin.system.users to dump/admin/system.users.bson
2021-08-19T09:11:04.036+0000	done dumping admin.system.users (1 document)
2021-08-19T09:11:04.038+0000	writing admin.system.version to dump/admin/system.version.bson
2021-08-19T09:11:04.042+0000	done dumping admin.system.version (2 documents)
2021-08-19T09:11:04.044+0000	writing test.test to dump/test/test.bson
2021-08-19T09:11:04.048+0000	done dumping test.test (5 documents)

mongorestore --drop dump
2021-08-19T09:11:05.021+0000	preparing collections to restore from
2021-08-19T09:11:05.026+0000	reading metadata for test.test from dump/test/test.metadata.json
2021-08-19T09:11:05.028+0000	dropping collection test.test before restoring
2021-08-19T09:11:05.058+0000	restoring test.test from dump/test/test.bson
2021-08-19T09:11:05.069+0000	finished restoring test.test (5 documents, 0 failures)
2021-08-19T09:11:05.070+0000	restoring users from dump/admin/system.users.bson
2021-08-19T09:11:05.111+0000	Failed: restore error: error running merge command: (Location40414) BSON field '_mergeAuthzCollections.tempRolesCollection' is missing but a required field
2021-08-19T09:11:05.111+0000	5 document(s) restored successfully. 0 document(s) failed to restore.

echo $?

If I drop the data and perform the restore the data and the user is correctly there.
If I drop also the user and perform the restore the user is gone.

The same process works without any problem with MongoDB 4.4.8

Do I make some mistake or is mongorestore currently broken when users are getting added. I looked already at the documentation of adding users, mongodump and mongorestore, but I can’t find anything I would need to do to get it working.
Did anyone saw this behaviour already or knows what to do to get the mongorestore done?

Having the exact same issue right now.
When importing dumps into mongodb 4.4.5 with mongorestore 100.5.0, made with mongoshell 4.4.1 and mongodump 100.2.0, everything is fine.
When importing the same dump with the same mongorestore into mongodb 5.0.1, I get the mentioned error.
When importing a dump made with mongoshell 5.0.1 and mongodump 100.5.0 into mongodb 5.0.1, I also get this error.