Hi Rohit
From the above message it is clear that createRole command needs atleast one inherited role
This is correct, as per db.createRole() page: “You must include the roles field. Use an empty array to specify no roles to inherit from.”
From the above statement, the role creation statement does not error out, but gives me a timeout error message.
If you don’t specify the write concern setting for db.createRole(), it will default to majority (see Write Concern for Replica Sets for more details).
Having said that, if the error was caused by a write concern timeout, it should output a different message, such as Error: waiting for replication timed out instead of just timeout.
There are some things you can check:
If you have more questions, please post:
rs.conf() and rs.status())Best regards
Kevin
Hi Rohit
Is the above behavior different for db.createRole command?
Yes, the default write concern for some user & role management commands are not using the “standard” w:1 write concern. Rather, they’re using w:majority.
This is reflected in the code for MongoDB 3.6.3 in this line.
However, I just noticed that this fact is not mentioned in the relevant documentation page. Thanks for bringing this oversight into attention. I have created DOCS-11378 to document this fact.
Best regards
Kevin