-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.20, 4.4.21
-
Component/s: None
-
Cluster Scalability
-
ALL
-
-
3
Inserting large number of documents (100k) into sharded collection fails with BSONObjectTooLarge after leader election:
batch op errors occurred, full error: {'writeErrors': [{'index': 0, 'code': 10334, 'codeName': 'BSONObjectTooLarge', 'errmsg': 'Write results unavailable from localhost:20508 :: caused by :: BSONObj size: 20437898 (0x137DB8A) is invalid. Size must be between 0 and 16793600(16MB) First element: n: 0', 'op': {'_id': ObjectId('644fd4c873ed9f40e707f8be'), 'x': 0}}, ..., {'index': 99999, 'code': 10334, 'codeName': 'BSONObjectTooLarge', 'errmsg': '', 'op': {'_id': ObjectId('644fd4c973ed9f40e7097f5d'), 'x': 99999}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []}
Rerunning the same insert immediately after will succeed.
This happens for both pymongo and the go-driver.
Additional note: under certain circumstances, running `db.adminCommand(
{ flushRouterConfig: "test.apricot" })` would avoid this error as well. I think doing so after a leader election works, but flushing before a leader election does not.