Hey, we are currently creating users dynamically for our multi tenant system. When a new tenant is created, we create his databases and collections. Then we create a new user that will be have read/write access only these databases. But sometimes we can not connect with the created credentials in timely manner.
Since we can not create users directly (unsupported command), we use the API. When the user is created he is not immediately able to connect with his credentials. I figured its because the created user is being propagated to the whole cluster - as can be seen from the blue notification about applying changes. So we have added a timeout and we try to connect with the created credentials before we continue - this has 10 tries every 3 seconds.
But, when we create 4 tenants either in parallel or sequentially - the third and fourth user can not connect - it takes more than a minute before the credentials can be used to connect to the database.
Is there some safer, ideally bulletproof method we can use to handle this use case?