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

Two or more indexes being created cannot be terminated normally

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.6, 5.0.25, 4.4.29, 6.0.14
    • Component/s: None
    • Labels:
    • Storage Execution
    • ALL
    • Hide

      createIndex with a big table in different createIndex

      db.ycsb_test_1705397142.createIndex({field5:1},{background:false}) 
      db.ycsb_test_1705397142.createIndex({field4:1},{background:false}) 

       

      then dropIndexes

      xxx:PRIMARY> db.runCommand({dropIndexes:"ycsb_test_1705397142",index:["field5_1","field4_1"]})
      {
              "operationTime" : Timestamp(1705489578, 2),
              "ok" : 0,
              "errmsg" : "cannot perform operation: a background operation is currently running for collection ycsb.ycsb_test_1705397142",
              "code" : 12587,
              "codeName" : "BackgroundOperationInProgressForNamespace",
              "$gleStats" : {
                      "lastOpTime" : {
                              "ts" : Timestamp(1705489578, 2),
                              "t" : NumberLong(7)
                      },
                      "electionId" : ObjectId("7fffffff0000000000000007")
              },
              "lastCommittedOpTime" : Timestamp(1705489578, 2),
              "$configServerState" : {
                      "opTime" : {
                              "ts" : Timestamp(1705489581, 2),
                              "t" : NumberLong(1)
                      }
              },
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1705489584, 1),
                      "signature" : {
                              "hash" : BinData(0,"VardSR5SDw0tB6/DTSC4h1YedKc="),
                              "keyId" : NumberLong("7313775769702891542")
                      }
              }
      } xx:PRIMARY> db.runCommand({dropIndexes:"ycsb_test_1705397142",index:"*"})
      {
              "nIndexesWas" : 3,
              "msg" : "non-_id indexes dropped for collection",
              "ok" : 1,
              "$gleStats" : {
                      "lastOpTime" : {
                              "ts" : Timestamp(1705491657, 3),
                              "t" : NumberLong(7)
                      },
                      "electionId" : ObjectId("7fffffff0000000000000007")
              },
              "lastCommittedOpTime" : Timestamp(1705491653, 1),
              "$configServerState" : {
                      "opTime" : {
                              "ts" : Timestamp(1705491651, 2),
                              "t" : NumberLong(1)
                      }
              },
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1705491657, 3),
                      "signature" : {
                              "hash" : BinData(0,"N0pxt8jtjreOWpAGsyfA8aC+D3Y="),
                              "keyId" : NumberLong("7313775769702891542")
                      }
              },
              "operationTime" : Timestamp(1705491657, 3)
      }
      Show
      createIndex with a big table in different createIndex db.ycsb_test_1705397142.createIndex({field5:1},{background: false }) db.ycsb_test_1705397142.createIndex({field4:1},{background: false })   then dropIndexes xxx:PRIMARY> db.runCommand({dropIndexes: "ycsb_test_1705397142" ,index:[ "field5_1" , "field4_1" ]}) {         "operationTime" : Timestamp(1705489578, 2),         "ok" : 0,         "errmsg" : "cannot perform operation: a background operation is currently running for collection ycsb.ycsb_test_1705397142" ,         "code" : 12587,         "codeName" : "BackgroundOperationInProgressForNamespace" ,         "$gleStats" : {                 "lastOpTime" : {                         "ts" : Timestamp(1705489578, 2),                         "t" : NumberLong(7)                 },                 "electionId" : ObjectId( "7fffffff0000000000000007" )         },         "lastCommittedOpTime" : Timestamp(1705489578, 2),         "$configServerState" : {                 "opTime" : {                         "ts" : Timestamp(1705489581, 2),                         "t" : NumberLong(1)                 }         },         "$clusterTime" : {                 "clusterTime" : Timestamp(1705489584, 1),                 "signature" : {                         "hash" : BinData(0, "VardSR5SDw0tB6/DTSC4h1YedKc=" ),                         "keyId" : NumberLong( "7313775769702891542" )                 }         } } xx:PRIMARY> db.runCommand({dropIndexes: "ycsb_test_1705397142" ,index: "*" }) {         "nIndexesWas" : 3,         "msg" : "non-_id indexes dropped for collection" ,         "ok" : 1,         "$gleStats" : {                 "lastOpTime" : {                         "ts" : Timestamp(1705491657, 3),                         "t" : NumberLong(7)                 },                 "electionId" : ObjectId( "7fffffff0000000000000007" )         },         "lastCommittedOpTime" : Timestamp(1705491653, 1),         "$configServerState" : {                 "opTime" : {                         "ts" : Timestamp(1705491651, 2),                         "t" : NumberLong(1)                 }         },         "$clusterTime" : {                 "clusterTime" : Timestamp(1705491657, 3),                 "signature" : {                         "hash" : BinData(0, "N0pxt8jtjreOWpAGsyfA8aC+D3Y=" ),                         "keyId" : NumberLong( "7313775769702891542" )                 }         },         "operationTime" : Timestamp(1705491657, 3) }

      After 4.4 version, index creation is done in the background, and is Simultaneous Indexing. We can execute dropIndexes to terminate the index being created.
       
      But there is such a scene:
      In a terminal creates an index named of a_1 for collection mycoll ; and another one creates an index named of b_1 for collection mycoll;
       
      That is, table mycoll has two indexes being created, with different buildUUIDs
       
      and now ,i will get errores when terminate the indexes
       

      cannot perform operation: a background operation is currently running for collection ycsb.mycoll

       
      I have to drop all the indexes on this table to drop the two indexes that were created, but that's not what I want.
       
      The key point is that the logic of deleting indexes does not support this scenario. It only supports the scenario of creating multiple indexes with the same buildUUID.
       
       

      /**
       * Aborts all the index builders on the collection if the first element in 'indexesToAbort' is "*",
       * otherwise this attempts to abort a single index builder building the given index names.
       */
      std::vector<UUID> abortActiveIndexBuilders(OperationContext* opCtx,
                                                 const NamespaceString& collectionNs,
                                                 CollectionUUID collectionUUID,
                                                 const std::vector<std::string>& indexNames) {
          if (indexNames.empty()) {
              return {};
          }    if (indexNames.front() == "*") {
              return IndexBuildsCoordinator::get(opCtx)->abortCollectionIndexBuilds(
                  opCtx, collectionNs, collectionUUID, "dropIndexes command");
          }    return abortIndexBuildByIndexNames(opCtx, collectionUUID, indexNames);
      }
      
      

       
       
      Maybe this is a bug and this scenario should be supported.

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            lpc FirstName lipengchong
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: