Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3409

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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.11.0
    • Component/s: None
    • Labels:
      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@mongodb.com Ross Lawley
            Reporter:
            pwirth Phillip Wirth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: