Can not run db.fsyncLock() in a MongoDB Atlas cluster

I’ve deployed a MongoDB sharded cluster in MongoDB Atlas dedicated. For some reason i am trying to run db.fsyncLock() from a secondary. But It’s giving me unauthorized error. I also tried many command like findAndModify a collection in config database, but same error. Though I give so many privilege to my user through Atlas UI.

My user has these roles:

authenticatedUserRoles: [
  { role: 'atlasAdmin', db: 'admin' },
  { role: 'backup', db: 'admin' },
  { role: 'clusterMonitor', db: 'admin' },
  { role: 'dbAdminAnyDatabase', db: 'admin' },
  { role: 'enableSharding', db: 'admin' },
  { role: 'readWriteAnyDatabase', db: 'admin' }
]

I am getting this error:

MongoServerError[Unauthorized]: not authorized on admin to execute command { fsync: 1, lock: true, lsid: { id: UUID(“3c98878b-9c36-4a5a-945f-f844bda6c04f”) }, $clusterTime: { clusterTime: Timestamp(1726470174, 1), signature: { hash: BinData(0, D048A6DCF75FA7B59DB4AE831656E536D1ED989A), keyId: 7415097913686097942 } }, $readPreference: { mode: “primaryPreferred” }, $db: “admin” }

Is there any to run these kind of command from Atlas managed MongoDB cluster?

Hi @Abu_Sayed1

This is an unsupported command on Atlas.

https://www.mongodb.com/docs/atlas/unsupported-commands/#std-label-unsupported-commands

There should be no reason to run this on Atlas. The primary reason is to flush and lock data files so they can be copied. There is no way for an Atlas user to access the data files.

Can you explain the use case ?

1 Like

Thanks @chris . We were trying to bring a generic database backup solution with restic. So that this command was needed.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.