[SERVER-52978] Ordered bulk insert no longer stops on bson validation errors in 4.9.0-alpha-660-g250d733 Created: 20/Nov/20  Updated: 29/Oct/23  Resolved: 25/Nov/20

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Shane Harvey Assignee: Daniel Gottlieb (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes PYTHON-2436 Test failure - test.test_legacy_api.T... Closed
is caused by SERVER-52667 write_ops_exec::performInserts with r... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2020-11-30
Participants:

 Description   

Ordered bulk insert no longer stops on error in 4.9.0-alpha-660-g250d733:

> db.version()
4.9.0-alpha-660-g250d733
> db.runCommand({'insert': 'test', 'ordered': true, 'documents': [{}, {'big': 'x'.repeat(db.isMaster().maxBsonObjectSize)}, {}]})
{
	"n" : 2,
	"writeErrors" : [
		{
			"index" : 1,
			"code" : 2,
			"errmsg" : "object to insert too large. size in bytes: 16777231, max size: 16777216"
		}
	],
	"opTime" : {
		"ts" : Timestamp(1605902265, 4),
		"t" : NumberLong(1)
	},
	"electionId" : ObjectId("7fffffff0000000000000001"),
	"ok" : 1
}

And here's the expected behavior using 4.4.0:

> db.version()
4.4.0
> db.runCommand({'insert': 'test', 'ordered': true, 'documents': [{}, {'big': 'x'.repeat(db.isMaster().maxBsonObjectSize)}, {}]})
{
	"n" : 1,
	"writeErrors" : [
		{
			"index" : 1,
			"code" : 2,
			"errmsg" : "object to insert too large. size in bytes: 16777231, max size: 16777216"
		}
	],
	"opTime" : {
		"ts" : Timestamp(1605902241, 2),
		"t" : NumberLong(1)
	},
	"electionId" : ObjectId("7fffffff0000000000000001"),
	"ok" : 1
}

Notice "n":2 in the first case and "n":1 in the second.



 Comments   
Comment by Shane Harvey [ 30/Nov/20 ]

Perfect, thanks for the quick fix!

Comment by Daniel Gottlieb (Inactive) [ 25/Nov/20 ]

Thanks for finding this shane.harvey. Trying to fix a control flow bug in that function was made all the harder due to an existing lack of testing. I'm a little embarrassed I didn't look deeper into that code path to make sure the tests I did add covered it.

Comment by Githook User [ 25/Nov/20 ]

Author:

{'name': 'Daniel Gottlieb', 'email': 'daniel.gottlieb@mongodb.com', 'username': 'dgottlieb'}

Message: SERVER-52978: Correct ordered batch inserts code path for document validation errors.
Branch: master
https://github.com/mongodb/mongo/commit/8e7ad370f7d35501a9fdd563456b361cbb133d86

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