-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
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
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);