[GODRIVER-648] Collection usage sometimes leads to CursorNotFound Created: 22/Nov/18 Updated: 27/Oct/23 Resolved: 15/Dec/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Connections, Server Selection |
| Affects Version/s: | 0.0.18 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Ivan Strelkov | Assignee: | Jeffrey Yemin |
| Resolution: | Works as Designed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
After moving from `mgo` to `mongo-go-driver` we started facing CursorNotFound errors when getting documents on one collection:
Here is the code used to search documents (error is triggered from cursor.Err() check):
After the error happens it continues appearing and stops after a certain amount of time. We noticed that error goes away after restarting the docker container with go code.
Driver version: 0.0.18 ( dbffb1c211bf96fbd721b4bd6911331e5c1886ab )
Go version:
mongos version:
|
| Comments |
| Comment by Jeffrey Yemin [ 30/Nov/18 ] |
|
I suspect the issue is that in this setup you are essentially using DNS as a load balancer, and the MongoDB wire protocol only supports load balancers that are configured to use "sticky sessions", which essentially means that for a given client IP every connection from that IP will connect to the same mongos server. Using DNS in this way doesn't fit that definition. I'm not exactly sure why this configuration works with mgo, but it will not work with any of the MongoDB-supported drivers. As a workaround, you will have to stop using multiple A records on a hostname and instead list each of the mongos servers explicitly in the connection string. |
| Comment by Ivan Strelkov [ 30/Nov/18 ] |
|
I see that the issue type was changed to question. Likely it means we did something wrong. Could you please tell us what was wrong on our side? |
| Comment by Ivan Strelkov [ 27/Nov/18 ] |
|
We had two mongos instances with different IP addresses. Connection string was `mongodb://<hostname>`, where <hostname> is resolved via DNS to both instances.
|
| Comment by Ian Whalen (Inactive) [ 26/Nov/18 ] |
|
istrel is it possible the connection string you're using is pointing to a load balancer rather than mongos endpoints? |