[SERVER-64078] Missing ErrMsg for Multiple Bulk Write Errors Created: 01/Mar/22  Updated: 29/Oct/23  Resolved: 03/Mar/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Steve Silvester Assignee: Kaloian Manassiev
Resolution: Fixed Votes: 0
Labels: PM-2144-Cleanup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes CSHARP-4083 TestInsertBatchContinueOnError failin... Closed
causes PHPC-2075 Bulk write test failures due to missi... Blocked
is caused by SERVER-63331 Use a proper IDL structure for the wr... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:
  • Install PyMongo 4+ and Mongo Latest in Evergreen
  • Run the code above
Sprint: Sharding EMEA 2022-03-07
Participants:

 Description   

The following code shows the appropriate error messages when used with Mongo 5.2:

  >>> from pymongo import InsertOne, DeleteOne, ReplaceOne
  >>> from pymongo.errors import BulkWriteError
  >>> requests = [
  ...     InsertOne({'_id': 1}),
  ...     DeleteOne({'_id': 2}),
  ...     InsertOne({'_id': 3}),
  ...     ReplaceOne({'_id': 4}, {'i': 1})]
  >>> try:
  ...     db.test.bulk_write(requests, ordered=False)
  ... except BulkWriteError as bwe:
  ...     pprint(bwe.details)
    {'nInserted': 0,
     'nMatched': 1,
     'nModified': 1,
     'nRemoved': 1,
     'nUpserted': 0,
     'upserted': [],
     'writeConcernErrors': [],
     'writeErrors': [{'code': 11000,
                      'errmsg': 'E11000 duplicate key error collection: '
                                'bulk_example.test index: _id_ dup key: { _id: 1 }',
                      'index': 0,
                      'keyPattern': {'_id': 1},
                      'keyValue': {'_id': 1},
                      'op': {'_id': 1}},
                     {'code': 11000,
                      'errmsg': 'E11000 duplicate key error collection: '
                                'bulk_example.test index: _id_ dup key: { _id: 3 }',
                      'index': 2,
                      'keyPattern': {'_id': 1},
                      'keyValue': {'_id': 3},
                      'op': {'_id': 3}}]}

When using Mongo Latest in Evergreen, we get the following output (note the empty errmsg in the second error object):

    {'nInserted': 0,
     'nMatched': 1,
     'nModified': 1,
     'nRemoved': 1,
     'nUpserted': 0,
     'upserted': [],
     'writeConcernErrors': [],
     'writeErrors': [{'code': 11000,
                      'errmsg': 'E11000 duplicate key error collection: '
                                'bulk_example.test index: _id_ dup key: { _id: 1 }',
                      'index': 0,
                      'keyPattern': {'_id': 1},
                      'keyValue': {'_id': 1},
                      'op': {'_id': 1}},
                     {'code': 11000,
                      'errmsg': '',
                      'index': 2,
                      'keyPattern': {'_id': 1},
                      'keyValue': {'_id': 3},
                      'op': {'_id': 3}}]}



 Comments   
Comment by Githook User [ 03/Mar/22 ]

Author:

{'name': 'Kaloian Manassiev', 'email': 'kaloian.manassiev@mongodb.com', 'username': 'kaloianm'}

Message: SERVER-64078 Only truncate error messages if they are bigger than 1M
Branch: master
https://github.com/mongodb/mongo/commit/c46cc6378e20219b1e98947dddc9cea1012d25b2

Comment by Kaloian Manassiev [ 02/Mar/22 ]

Confirming that this bug was caused by my changes for SERVER-63331. I will be working today to fix that and write a test. Thank you for reporting it.

Comment by Kaloian Manassiev [ 01/Mar/22 ]

This might be related to SERVER-63331 which I recently committed, investigating ...

Generated at Thu Feb 08 05:59:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.