Index with name: _key_1_value_-1 already exists with different options



  • Hi.. i just tried to upgrade to the last version but im getting a mongodb error..
    this is the last commit om the branch v1.x.x

    commit d120ee86cfe2a55efcd3982cc3e8fa3f71284602
    Author: Misty (Bot) <deploy@nodebb.org>
    Date:   Thu Dec 1 21:28:53 2016 +0000
    
    Incremented version number
    

    This is the error trying to .upgrade...

    3. Updating NodeBB data store schema...    
    5/12 09:42 [15858] - error: MongoError: exception: Index with name: _key_1_value_-1 already exists with different options
    at Function.MongoError.create (/home/forum/NodeBB/node_modules/mongodb-core/lib/error.js:31:11)
    at /home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:462:72
    at authenticateStragglers (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:410:16)
    at null.messageHandler (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:444:5)
    at Socket.<anonymous> (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/connection.js:306:22)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:529:20)
    
    Error: undefined
    

    This is my mongo version:

    MongoDB shell version: 3.0.14

  • Admin

    Try dropping the indices first then running upgrade again.



  • Listed all the indexes as the official doc says: https://docs.mongodb.com/v3.2/tutorial/manage-indexes/

    now i only have the index that the mongo cant drop:

    Indexes for objects:
    
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.objects"
    }
    ]
    Indexes for search:
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.search"
    }
    ]
    Indexes for searchpost:
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.searchpost"
    }
    ]
    Indexes for searchtopic:
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.searchtopic"
    }
    ]
    Indexes for sessions:
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.sessions"
    }
    ]
    Indexes for system.indexes:
    [ ]
    Indexes for system.users:
    [
    {
    	"v" : 1,
    	"key" : {
    		"_id" : 1
    	},
    	"name" : "_id_",
    	"ns" : "nodebb.system.users"
    }
    ]


  • But it still cant upgrade it...

    getting other error:

    5/12 12:09 [16752] - info: [database] Checking database indices.
    5/12 12:09 [16752] - error: Error creating index exception: E11000 duplicate key error index: nodebb.objects.$_key_1_value_-1 dup key: { : "ip:recent", : "10.y.x.14c" }
    5/12 12:09 [16752] - info: [database] Checking database indices done!
    5/12 12:09 [16752] - error: MongoError: exception: E11000 duplicate key error index: nodebb.objects.$_key_1_value_-1 dup key: { : "ip:recent", : "10.y.x.14c" }
    at Function.MongoError.create (/home/forum/NodeBB/node_modules/mongodb-core/lib/error.js:31:11)
    at /home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:462:72
    at authenticateStragglers (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:410:16)
    at null.messageHandler (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/pool.js:444:5)
    at Socket.<anonymous> (/home/forum/NodeBB/node_modules/mongodb-core/lib/connection/connection.js:306:22)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:529:20)
    
    Error: undefined
    

    (changed the ip address)


  • Admin

    Do you get the same error when you run ./nodebb upgrade again?



  • yep.. the same error

    5/12 12:09 [16752] - error: MongoError: exception: E11000 duplicate key error index: nodebb.objects.$_key_1_value_-1 dup key: { : "ip:recent", : "10.y.x.14c" }
    at Function.MongoError.create (/home/forum/NodeBB/node_modules/mongodb-core/lib/error.js:31:11)

  • Admin

    You can try removing that document and try running ./nodebb upgrade

    db.objects.remove({_key: "ip:recent", value: "insert ip here"});
    


  • ok.. after deleting a few recent ips.. (like..12...) it worked out... wondering why it happend... 😞


  • Admin

    Read more here about why it happens https://github.com/NodeBB/NodeBB/issues/4467


  • Plugin & Theme Dev

    i have the same problem...


  • Plugin & Theme Dev

    6/12 13:55 [3733] - error: Error creating index exception: E11000 duplicate key error index: exodef.objects.$key_1_value-1 dup key: { : "uid:2229:chat:rooms", : "1371" }
    6/12 13:55 [3733] - info: [database] Checking database indices done!
    6/12 13:55 [3733] - error: MongoError: exception: E11000 duplicate key error index: exodef.objects.$key_1_value-1 dup key: { : "uid:2229:chat:rooms", : "1371" }
    at Function.MongoError.create (/var/foroexodo/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11)
    at /var/foroexodo/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:462:72
    at authenticateStragglers (/var/foroexodo/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:410:16)
    at null.messageHandler (/var/foroexodo/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:444:5)
    at Socket.<anonymous> (/var/foroexodo/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:306:22)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:537:20)

    Error: undefined


  • Plugin & Theme Dev

    it worked after dropping 30 objects...
    good luck on standard users solving this lol


 

| |