Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10684

Multiple indexes created when ensureIndex is called a lot with background = True

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.4
    • Index Maintenance
    • None
    • Ubuntu
    • ALL
    • Hide

      Create about (in our case 80) different threads that call ensureIndex with the same index spec, and background = True.

      Show
      Create about (in our case 80) different threads that call ensureIndex with the same index spec, and background = True.

    Description

      Part of our mongodb model code involves calling ensureIndex() with background = True rather frequently. Or, did. We had to change it because it was creating literally hundreds of db.currentOp() entries relating to building the same index over and over. Our end result even after putting in a safe guard (which checks pymongo.index_information to see if anyone is creating this index) is ridiculous:

      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "dealer_1.item",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "a" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "a_1"
      },
      {
      "v" : 1,
      "key" :

      { "s" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "s_1"
      },
      {
      "v" : 1,
      "key" :

      { "s" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "s_1"
      },
      {
      "v" : 1,
      "key" :

      { "u" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "u_1"
      },
      {
      "v" : 1,
      "key" :

      { "a" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "a_1"
      },
      {
      "v" : 1,
      "key" :

      { "a" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "a_1"
      },
      {
      "v" : 1,
      "key" :

      { "s" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "s_1"
      },
      {
      "v" : 1,
      "key" :

      { "u" : 1 }

      ,
      "ns" : "dealer_1.item",
      "background" : true,
      "name" : "u_1"
      }
      ]

      As you can see, multiple indexes with the same key, namespace, and name. This is troubling.

      Attachments

        Activity

          People

            Unassigned Unassigned
            shadowman131 Walt Woods
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: