Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-512

GridFS does not read from secondary nodes

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.0-beta0
    • Affects Version/s: 1.2-rc0
    • Component/s: GridFS
    • None

      (ported from github)

      read_prefs = mongoc_read_prefs_new(MONGOC_READ_SECONDARY);
      mongoc_client_set_read_prefs(client, read_prefs);
      .....
      gridfs = mongoc_client_get_gridfs (client, "test", "fs", &error);
      ....
      mongoc_gridfs_find_one_by_filename(gridfs, filename, &error);
      

      gridfs would create "filename" index everytime, and it can not link to secondary at all.

      Using the same config, bson object can read from secondary node. The c++, csharp,and python gridfs implementations allow reads from secondary nodes.

      read mode add when link chunks&files

      (from mongoc-gridfs.c)

      bson_snprintf (buf, sizeof(buf), "%s.chunks", prefix);
      //gridfs->chunks = _mongoc_collection_new (client, db, buf, NULL, NULL);
      
      gridfs->chunks = _mongoc_collection_new (client, db, buf, client->read_prefs, NULL);
      
      bson_snprintf (buf, sizeof(buf), "%s.files", prefix);
      // gridfs->files = _mongoc_collection_new (client, db, buf, NULL, NULL);
      gridfs->files = _mongoc_collection_new (client, db, buf, client->read_prefs, NULL);
      

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            samantha.ritter@mongodb.com Samantha Ritter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: