[GODRIVER-1187] Find() uses a write selector instead of a read selector Created: 03/Jul/19  Updated: 28/Oct/23  Resolved: 08/Jul/19

Status: Closed
Project: Go Driver
Component/s: CRUD
Affects Version/s: None
Fix Version/s: 1.1.0

Type: Bug Priority: Blocker - P1
Reporter: David Golden Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by TOOLS-2326 read_preference_and_tags.js fails aft... Closed

 Description   

In the master branch, the Find() command uses selector := makePinnedSelector(sess, coll.writeSelector) but it should use a read selector as the default to makePinnedSelector.

This bug blocks mongotools 4.2 support, as it breaks read preference support in tools.



 Comments   
Comment by Githook User [ 08/Jul/19 ]

Author:

{'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}

Message: Use readSelector in Collection.Find

GODRIVER-1187

Change-Id: Ibc04ef373d8f130ba05a1487b5081360df4ae8d9
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/216e392ea5ac0903291d940c2574a11a185663bd

Comment by David Golden [ 04/Jul/19 ]

I've tested this change and the failing test passes:

diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/collection.go b/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
index a54beeef..ae8c46bd 100644
--- a/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
+++ b/vendor/go.mongodb.org/mongo-driver/mongo/collection.go
@@ -955,7 +955,7 @@ func (coll *Collection) Find(ctx context.Context, filter interface{},
        rc = nil
    }
 
-   selector := makePinnedSelector(sess, coll.writeSelector)
+   selector := makePinnedSelector(sess, coll.readSelector)
 
    op := operation.NewFind(f).
        Session(sess).ReadConcern(rc).ReadPreference(coll.readPreference).

I believe divjot.arora is putting this change into code review. It would be very helpful to get this merged to master early next week.

Generated at Thu Feb 08 08:35:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.