[CDRIVER-644] bson_error_t's "code" is often wrong Created: 12/May/15 Updated: 08/Jan/24 Resolved: 04/Apr/16 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | errors |
| Affects Version/s: | None |
| Fix Version/s: | 1.4.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Major Change | ||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
The mongoc_error_code_t enum does not agree with the server's error codes. For example, recent servers return error code 13 if a command is unauthorized, but 13 means MONGOC_ERROR_CLIENT_IN_EXHAUST in the enum. MONGOC_ERROR_CLIENT_AUTHENTICATE, on the other hand, is 11 in the enum. Nevertheless, when a command fails on the server the driver sets the bson_error_t's code to the server error code, as if the enum values and the server's values were related. Applications comparing a bson_error_t's "code" field to the enum values are often misinformed about the cause of the error. The enum and bson_error_t can't work as designed – the client and server can't share that list of codes, because they don't agree now and can't be made to agree in the future. I need to investigate if there is a simple upgrade path, or if I just need to document the problem now and wait for version 2.0 for a true fix. |
| Comments |
| Comment by Githook User [ 02/Sep/16 ] | ||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | ||
| Comment by Githook User [ 04/Apr/16 ] | ||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | ||
| Comment by Githook User [ 04/Apr/16 ] | ||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | ||
| Comment by A. Jesse Jiryu Davis [ 29/Jan/16 ] | ||
|
Current server error codes are here: https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err There might be a handful, like duplicate key error, for which applications commonly have specialized error-handling logic. Those are well-known error codes have been stable in the server for many years, so we can make client-side error codes for those in the MONGOC_ERROR_SERVER domain. We have to come up with a list of those codes, and maybe agree on a drivers spec for the list. | ||
| Comment by A. Jesse Jiryu Davis [ 28/Jan/16 ] | ||
|
The root problem is that errors with QUERY or COMMAND domains, perhaps other domains as well, include error codes that might be client error codes or server error codes. There's no way to know for sure, but the meanings of the two sets of codes are different, so there isn't a clear way to diagnose an error based on its code. We'll go with a solution proposed by mira.carey@mongodb.com. Two new functions:
The default error API version is 1, the current broken behavior. Set the version to 2 and all server errors are now reported in a new domain, MONGOC_ERROR_SERVER. These errors have no meaning in the driver, they are simply the number returned by the server. |