Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.92k stars 3.84k forks source link

Only authenticated against one instance when connecting to multiple mongos (Compose.com) #7544

Closed christopherhex closed 5 years ago

christopherhex commented 5 years ago

Do you want to request a feature or report a bug? bug What is the current behavior? We're using a connection string that contains the two mongos urls:

mongodb://<user>:<pass>@<host1>:<port1>,<host2>:<port2>/dbname?ssl=true

What we're seeing is that mongoose/mongodb is sending queries to both mongos instances, but is only correctly authenthicated against one, giving a lot of not authorized on <db> to execute command.

Please mention your node.js, mongoose and MongoDB version.

vkarpov15 commented 5 years ago

I'm not going to be able to realistically repro this because compose no longer allows spinning up MongoDB instances:

image

Here's a couple thoughts to help out though:

1) Users aren't stored on mongos instances, they're stored in the config servers for the sharded cluster. If auth fails against one mongos but not the other, that probably means that you're connecting to two separate sharded clusters. Is the URI you're using the uri that compose recommends?

2) How did you set up your users? Via createUser() in the mongodb shell, via compose's UI, somewhere else?