Prabhu Kathiresan
Prabhu Kathiresan

Reputation: 57

Mongo replication issue in system.user database

I am able to add a user to systems.users collection when I register from primary node, But when I add a user from secondary node, value is not getting updated in the primary and so the replication fails, primary is in US and secondary is in Europe.


    var user = {
            user: email,
            pwd: password,
            roles: [
                {
                    role: "readWrite",
                    db: "newUser"
                }
            ]
        };
    db.addUser(user);
    res.send('added');

Am I missing anything?

Upvotes: 0

Views: 88

Answers (1)

JJussi
JJussi

Reputation: 1580

As mkorszun wrote, every write operation MUST be done at primary. You can of course read from secondary, if you set slaveOk=true.

Upvotes: 1

Related Questions