[CDRIVER-662] Inconsistent errs from CRUD functions Created: 18/May/15  Updated: 19/Oct/16  Resolved: 18/Oct/16

Status: Closed
Project: C Driver
Component/s: Bulk API, errors, libmongoc
Affects Version/s: None
Fix Version/s: 1.5.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:
Depends
depends on CDRIVER-654 Ordered bulk insert continues past ov... Closed
Related
is related to CDRIVER-644 bson_error_t's "code" is often wrong Closed

 Description   

Inserting a document larger than 16MB sometimes sets error.domain to MONGOC_ERROR_COMMAND with a legacy insert, sometimes MONGOC_ERROR_QUERY with an insert command. It should always be MONGOC_ERROR_BSON.

mongoc_collection_insert, insert_bulk, update, and delete sometimes set error.domain to MONGOC_ERROR_COLLECTION, sometimes to MONGOC_ERROR_COMMAND.



 Comments   
Comment by Githook User [ 18/Oct/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-662 consistent errs from CRUD functions.

mongoc_collection_insert, mongoc_collection_update, and
mongoc_collection_remove consistently use domain MONGOC_ERROR_BSON, code
MONGOC_ERROR_BSON_INVALID if passed oversized BSON, and
MONGOC_ERROR_COLLECTION for other errors.

mongoc_bulk_operation_execute continues to use MONGOC_ERROR_COMMAND for
all errors.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/f36c20c51fe52aac49d962bda0c718bf3b7da064

Comment by A. Jesse Jiryu Davis [ 14/Oct/16 ]

I need to update _mongoc_write_result_merge_legacy and _mongoc_write_result_complete() so they do not overwrite the mongoc_write_result_t's error domain once it's been set by too_large_error().

The legacy write error path is:

mongoc_collection_insert
  _mongoc_write_command_execute
    _mongoc_write_command_insert_legacy (&result->error)
      too_large_error (&result->error)  // sets ERROR_BSON, 2
      _mongoc_write_result_merge_legacy // don't overwrite result->error.domain
  _mongoc_write_result_complete // don't overwrite result->error.domain

The write command error path is:

mongoc_collection_insert
  _mongoc_write_command_execute
    _mongoc_write_command (&result->error)
      too_large_error (&result->error)  // sets ERROR_BSON, 2
  _mongoc_write_result_complete // don't overwrite result->error.domain

Comment by A. Jesse Jiryu Davis [ 14/Oct/16 ]

Here's a table of (error.domain, error.code) when calling various functions with an oversized document and the current code, 1.5.0-rc2:

  error api version 1 error api version 1 error api version 2 error api version 2
  server 2.4 server 3.2 server 2.4 server 3.2
mongoc_collection_insert ERROR_COMMAND, 2 ERROR_BSON, 2 ERROR_SERVER, 2 ERROR_BSON, 2
mongoc_collection_insert_bulk ERROR_COMMAND, 2 ERROR_BSON, 2 ERROR_SERVER, 2 ERROR_BSON, 2
mongoc_collection_update ERROR_CLIENT, TOO_BIG ERROR_BSON, 2 ERROR_CLIENT, TOO_BIG ERROR_BSON, 2
mongoc_collection_remove ERROR_CLIENT, TOO_BIG ERROR_BSON, 2 ERROR_CLIENT, TOO_BIG ERROR_BSON, 2
bulk op ERROR_CLIENT, TOO_BIG ERROR_BSON, 2 ERROR_CLIENT, TOO_BIG ERROR_BSON, 2
Comment by Githook User [ 11/Jul/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-662 relax error checking in bulk tests
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/94d3c1534a5c226a2310a83012eb7f6e7e486d0d

Generated at Wed Feb 07 21:10:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.