[SERVER-76712] Inserting large number of documents (100k) into sharded collection fails with BSONObjectTooLarge after leader election Created: 01/May/23  Updated: 12/Dec/23

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: 4.4.20, 4.4.21
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Craven Huynh Assignee: Backlog - Cluster Scalability
Resolution: Unresolved Votes: 0
Labels: sharding-nyc-subteam2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive logs.zip     File repro.py    
Issue Links:
Depends
Related
Assigned Teams:
Cluster Scalability
Operating System: ALL
Steps To Reproduce:

Steps to reproduce documented here:

https://jira.mongodb.org/browse/REP-2508?focusedCommentId=5391033&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-5391033

Participants:
Story Points: 3

 Description   

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.


Generated at Thu Feb 08 06:33:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.