8

after migrating replica set to standalone I have some weird issues with the resulting MongoDB setup. For example, an index on a collection is missing. But trying to reIndex() the collection fails as well with this error message:

> db.members.reIndex()
{
    "errmsg" : "exception: dictionary myapp.members.$channel_id_1 should exist, but we got ENOENT",
    "code" : 16988,
    "ok" : 0
}

The question is how to reindex a collection that misses its index :)

Many thanks in advance, Chris

turivishal
  • 34,368
  • 7
  • 36
  • 59
ctp
  • 1,077
  • 1
  • 10
  • 28
  • This is an interesting problem, it might be good to find out how you caused this inconsistency, anyway can't you just run ensureInde() to remake that inde? – Sammaye Jul 30 '14 at 09:12
  • You tried to db.collection.reIndex() ? http://docs.mongodb.org/manual/reference/command/reIndex/ – Barno Jul 30 '14 at 09:21
  • @Barno: yes, exactly what I did, see my post above :) – ctp Jul 30 '14 at 09:22
  • sorry! today I'm slow :).. I need a Coffee – Barno Jul 30 '14 at 09:24
  • @Sammaye: ensureIndex() returns me the same error message. The question is: would it help to remove all local.* data files and restart the MongoDB? All the metadata will be recreated automatically, right? – ctp Jul 30 '14 at 09:24
  • Yeah, though it is a harsh way but that might be the only way :( I really know of no better way – Sammaye Jul 30 '14 at 09:33
  • Can you show us the output of `db.members.getIndexes()`? Have you tried dropping the index and then re-ensuring it? I'm curious to know how you did the migration to standalone as well. – wdberkeley Jul 31 '14 at 17:54
  • have you tried running db.repairdatabase()? – Dylan Brams Oct 30 '18 at 15:46
  • Looks like your migration failed, despite the fact that you did not notice any errors. If you still have your replica set, I would first verify that it is healthy and then run the migration again. If you don't have the replica set anymore, then I would try deleting the collection and restoring it from backup. – Old Pro Oct 30 '18 at 22:44
  • Looks like an unclean / inconsistent file copy. As others have said, go back to some sort of good working copy. Since you migrated to a standalone, we will assume you don't really care about your data. :-) – helmy Nov 02 '18 at 02:00
  • do you have list on indexes on members collection before migration? Did you take any backup before converting replica set to standalone? – Atish Nov 04 '18 at 08:31

0 Answers0