[SERVER-9379] getIndexes returns duplicated indexes Created: 17/Apr/13  Updated: 10/Dec/14  Resolved: 20/May/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.2.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Marcio Trindade Assignee: Thomas Rueckstiess
Resolution: Cannot Reproduce Votes: 0
Labels: duplication, index
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: Linux
Participants:

 Description   

When I run the function "getIndexes" I got duplicated results for a specific index (account_id_1_list_ids_1_status_1) with the same key.

db.contacts.getIndexes()
[
  {
    "v" : 1,
    "key" : {
      "_id" : 1
    },
    "ns" : "emailmarketing_production.contacts",
    "name" : "_id_"
  },
  {
    "v" : 1,
    "key" : {
      "account_id" : 1,
      "list_ids" : 1,
      "status" : 1
    },
    "ns" : "emailmarketing_production.contacts",
    "name" : "account_id_1_list_ids_1_status_1",
    "background" : true
  },
  {
    "v" : 1,
    "key" : {
      "account_id" : 1,
      "list_ids" : 1,
      "status" : 1
    },
    "ns" : "emailmarketing_production.contacts",
    "name" : "account_id_1_list_ids_1_status_1",
    "background" : true
  }
]



 Comments   
Comment by Thomas Rueckstiess [ 08/May/13 ]

Hi Marcio,

Thanks for the additional information and I'm glad to hear that you were able to fix the problem. Can I ask how you determined that the index was not working on the secondary? Even in stand-alone mode, it should not be possible to add an index again that is already existing. I've tried to reproduce your steps but without success.

If you do find the log files covering these events, please let us know. Without them, unfortunately there is not much to go on to find out how you ended up with the multiple indexes.

Best regards,
Thomas

Comment by Marcio Trindade [ 06/May/13 ]

Hi Thomas,

1 - I don't remember.
2 - I think no, but I'll check it.
3 - It's a part of replicaset and we not using sharding
4 - It's a secondary node.
5 - No we never change system.indexes manually.

PS. Let me try to explain how it's happen:
I got a new empty server and added to the replicaset. When the sync is ended I checked that the index it was there, but did not work to find documents.
So I stopped the mongod, changed the configuration and start it in alone mode.
I added that index again (by hand).
When I returned the node to the replicaset I checked that the index was working, but it was duplicated.

Now it's ok because I removed stop mongod again, remove the index and create it again.

Thank you,

Comment by Thomas Rueckstiess [ 06/May/13 ]

Hi Marcio,

We wouldn't expect the index to appear multiple times in the system.indexes collection. Are you aware of any issues that you had recently with this node? I.e. multiple restarts while an index may have been building?

Can you also provide more information on your system:

  1. Do you remember when this index was being created originally?
  2. If so, do you have log files going back that far?
  3. Is this a stand-alone node, part of a single replica set or of a sharded environment?
  4. Is this node a primary or secondary (if applicable)?
  5. Did you ever modify or attempt to modify the system.indexes collection manually?

It's difficult to say where the multiple entries came from. To fix the issue: If this is part of a replica set, can you check if the other nodes also have the multiple entries in their system.indexes collection on the emailmarketing_production database? If they don't, you could promote one secondary to primary, and resync this current node from it.

Regards,
Thomas

Comment by Marcio Trindade [ 25/Apr/13 ]

Hi Dan,

Here the result.

{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "emailmarketing_production.contacts", "name" : "_id_" }
{ "v" : 1, "key" : { "account_id" : 1, "list_ids" : 1, "status" : 1 }, "ns" : "emailmarketing_production.contacts", "name" : "account_id_1_list_ids_1_status_1", "background" : true }
{ "v" : 1, "key" : { "account_id" : 1, "list_ids" : 1, "status" : 1 }, "ns" : "emailmarketing_production.contacts", "name" : "account_id_1_list_ids_1_status_1", "background" : true }
{ "v" : 1, "key" : { "account_id" : 1, "list_ids" : 1, "status" : 1 }, "ns" : "emailmarketing_production.contacts", "name" : "account_id_1_list_ids_1_status_1", "background" : true }
{ "v" : 1, "key" : { "account_id" : 1, "list_ids" : 1, "status" : 1 }, "ns" : "emailmarketing_production.contacts", "name" : "account_id_1_list_ids_1_status_1", "background" : true }

If you need something else please send it to me.

Thank you

Comment by Daniel Pasette (Inactive) [ 25/Apr/13 ]

Hi Marcio, can you post the results of running:

use emailmarketing_production
db.system.indexes.find()

Generated at Thu Feb 08 03:20:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.