[GODRIVER-1019] why insert duplicate document close the client? Created: 05/May/19 Updated: 27/Oct/23 Resolved: 20/May/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | CRUD |
| Affects Version/s: | 1.0.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | daniel yang | Assignee: | Divjot Arora (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
set GOARCH=amd64 |
||
| Description |
|
After I create an unique index for a field of a document, I insert a duplicate document into mongodb, when using mgo it reports duperr, but user this driver, it reports "client is disconnected" and it disconnects from server either.
IMO, this error should not close the connection to the mongodb server, but just report/return an proper error.
|
| Comments |
| Comment by daniel yang [ 18/May/19 ] |
|
Thanks for reply, please close it. I found that there is a defer close in the init function for mongodb client, resolved by remove it . |
| Comment by Divjot Arora (Inactive) [ 06/May/19 ] |
|
yyq Can you confirm that you are calling client.Connect before calling InsertOne? The GoDoc for the driver contains an example of this: https://godoc.org/go.mongodb.org/mongo-driver/mongo. |