GridFS indexes do not created when database is restored with --noIndexRestore

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.11.0
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When restoring a database with {{ --noIndexRestore}} the gridfs indexes, named here do not get created again IF there are already files in grid fs.

      Expected:

      the indexes get created.

      the current code from the 3.11.0 driver is:

      
      private void checkCreateIndex(@Nullable final ClientSession clientSession) {
       if (!checkedIndexes) {
       if (collectionIsEmpty(clientSession, filesCollection.withDocumentClass(Document.class).withReadPreference(primary()))) {
       Document filesIndex = new Document("filename", 1).append("uploadDate", 1);
       if (!hasIndex(clientSession, filesCollection.withReadPreference(primary()), filesIndex)) {
       createIndex(clientSession, filesCollection, filesIndex, new IndexOptions());
       }
       Document chunksIndex = new Document("files_id", 1).append("n", 1);
       if (!hasIndex(clientSession, chunksCollection.withReadPreference(primary()), chunksIndex)) {
       createIndex(clientSession, chunksCollection, chunksIndex, new IndexOptions().unique(true));
       }
       }
       checkedIndexes = true;
       }
      }
      
      

       

            Assignee:
            Ross Lawley
            Reporter:
            Phillip Wirth
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: