[SERVER-24012] Clean up WriteConcernErrorDetail class and use it instead of a Status where appropriate Created: 02/May/16 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Replication, Sharding |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Spencer Brody (Inactive) | Assignee: | Backlog - Replication Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | ds-neweng-2016, neweng, writeconcern | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Replication
|
| Sprint: | Sharding 16 (06/24/16), Repl 2016-11-21 |
| Participants: |
| Description |
|
Currently the getWriteConcernStatusFromCommandResult function returns a Status, but that loses some information includes in a write concern response, such as the 'errInfo' field. We should make WriteConcernErrorDetail easier to construct and parse from BSON, then use it anywhere we deal with write concern error responses (such as in Shard::CommandResponse) |
| Comments |
| Comment by William Schultz (Inactive) [ 02/Dec/16 ] |
|
After some investigation, the following is a suggested aid/approach to resolving this ticket Normal database commands that cause an error will return result objects with the fields {ok: int, code:int, errmsg: string} Note that we have existing logic to interpret normal command result objects as Status objects (src/mongo/base/status.h) in get_status_from_command_result.cpp. WriteConcernError objects, which appear in the field 'writeConcernError' of command result objects, take on the form {code: int, errmsg: string, errInfo: Object} Since this object has a 'code' and an 'errmsg' field, it can really just be interpreted as a normal Status, of the error kind, with one extra piece of information (errInfo). I would recommend factoring out the common parsing logic for "status-like" objects in get_status_from_command_result.cpp, and perhaps let the WriteConcernErrorDetail class contain a Status object as a member, and one additional 'errInfo' member. The core idea here is to interpret writeConcernError objects as Status objects, with a bit of extra metadata. This was motivated by the recognition that parsing BSON with proper error handling is not so clean to do in the C++ codebase, so it would be nice to consolidate it as much as possible. Additionally, it simplifies things by not tacking on unnecessarily complicated semantics to the WriteConcernErrorDetail class, when it essentially inherits the same core properties as a normal Status object. |
| Comment by Spencer Brody (Inactive) [ 23/Jun/16 ] |
|
There are places currently, such as ShardingCatalogClientImpl::runUserManagementWriteCommand where we lose the 'errInfo' object in the response that we return to the user, where making this change would allow us to report that information to the user correctly. |