Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoError: E11000 duplicate key error #14

Open
clarkritchie opened this issue Dec 2, 2015 · 12 comments
Open

MongoError: E11000 duplicate key error #14

clarkritchie opened this issue Dec 2, 2015 · 12 comments

Comments

@clarkritchie
Copy link

We sometimes see this error -- any thoughts?

Exception while invoking method 'requestPhoneVerification' MongoError: E11000 duplicate key error index: mydb.users.$services.phone.verify.code_1 dup key: { : "1699" }
@ahmedtabrez
Copy link

@idanwe, How do you create users? Accounts.createUser() or Accounts.createUserWithPhone()

@clarkritchie
Copy link
Author

var id = Accounts.createUserWithPhone(user);

@ahmedtabrez
Copy link

Looks like a problem in your schema. Are you using SimpleSchema ? If yes, Can you post your UserSchema here ?

@clarkritchie
Copy link
Author

Not using SimpleSchema...

@ahmedtabrez
Copy link

@clarkritchie, were you able to solve it ??? can you post a lil code here ...

Also check if your mongodb has indexes (on the key services or its subkeys phone or phone.verify in the users collection) that you do not want. You may need to remove it manually using robomongo or other mongo client. Though I wonder how it got created. Perhaps by another package.

You may also find it easier to meteor reset if you are on development server.

@clarkritchie
Copy link
Author

@ahmedtabrez Honestly, I've never messed with Mongo indexes!

Here's what I've got -- your suggestion is to drop the index on services.phone.verify.code, is that right?

> db.users.getIndexes()
[
    {
        "v" : 1,
        "key" : {
            "_id" : 1
        },
        "name" : "_id_",
        "ns" : "myawesomedb.users"
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "username" : 1
        },
        "name" : "username_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "emails.address" : 1
        },
        "name" : "emails.address_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "services.resume.loginTokens.hashedToken" : 1
        },
        "name" : "services.resume.loginTokens.hashedToken_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "services.resume.loginTokens.token" : 1
        },
        "name" : "services.resume.loginTokens.token_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "key" : {
            "services.resume.haveLoginTokensToDelete" : 1
        },
        "name" : "services.resume.haveLoginTokensToDelete_1",
        "safe" : true,
        "sparse" : 1,
        "ns" : "myawesomedb.users"
    },
    {
        "v" : 1,
        "key" : {
            "services.resume.loginTokens.when" : 1
        },
        "name" : "services.resume.loginTokens.when_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "phone.number" : 1
        },
        "name" : "phone.number_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    },
    {
        "v" : 1,
        "unique" : true,
        "key" : {
            "services.phone.verify.code" : 1
        },
        "name" : "services.phone.verify.code_1",
        "ns" : "myawesomedb.users",
        "safe" : true,
        "sparse" : 1
    }
]
>

@ahmedtabrez
Copy link

@clarkritchie , Drop the indexes manually and restart your application. If the indexes come back, Probably there is another package or another part of code which is playing with Meteor.users._ensureIndex().

@clarkritchie
Copy link
Author

Thanks, I'll give that a shot. Maybe the EasySearch package created that index. I didn't create them manually... Appreciate the suggestion!

@clarkritchie
Copy link
Author

Thanks again, confirmed it's coming from the Meteor EasySearch package. Cheers!

@clarkritchie
Copy link
Author

clarkritchie commented May 2, 2016

Re-opening this one. We have 10,000 users in our application a lot of which are unverified, now and I get this error frequently when adding a new user.

@clarkritchie
Copy link
Author

@airstep
Copy link

airstep commented Mar 10, 2019

Same for me - any receipt to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants