[CDRIVER-3035] Always allow bulk OP_INSERTs to accommodate unacknowledged write concerns Created: 22/Mar/19  Updated: 28/Oct/23  Resolved: 07/Nov/19

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.16.0

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 3.4 and earlier


Issue Links:
Depends
is depended on by PHPC-1351 executeBulkWrite() does not use bulk ... Closed
Related
related to CDRIVER-2573 APM reports incorrect command documen... Backlog

 Description   

Original description: mongoc_collection_insert_many() does not batch legacy inserts for unacknowledged write concerns

While investigating PHPC-1351 and other places where allow_bulk_op_insert was set, I came across the three collection-level insert methods. mongoc_collection_insert_bulk() (since deprecated) always allows bulk inserts when calling _mongoc_write_command_init_insert(), but mongoc_collection_insert_one() and mongoc_collection_insert_many() never allow bulk inserts. This isn't a problem for the insert-one case, but it appears that mongoc_collection_insert_many() may not batch inserts for unacknowledged write concerns when connected to MongoDB versions before 3.6.

I quickly tested this by modifying example-command-monitoring.c to connect to a MongoDB 3.4 server using w=0. Running the example file shows that three insert commands are issued when I would expect two.



 Comments   
Comment by Githook User [ 07/Nov/19 ]

Author:

{'name': 'Jeremy Mikola', 'username': 'jmikola', 'email': 'jmikola@gmail.com'}

Message: CDRIVER-3035 allow bulk OP_INSERT for w:0 insert_many

Since libmongoc requires MongoDB 3.0+, OP_INSERT is only used for w:0
writes. The allow_bulk_op_insert flag is removed since there is no need
to limit OP_INSERT to single inserts.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/8c5da424138c0ccf38ad241645b2d4a13e6cb2cb

Comment by Jeremy Mikola [ 01/Nov/19 ]

Note: 129be86 removed write concern args for legacy write methods, since CDRIVER-2243 dropped support for MongoDB 2.4 and acknowledged writes could always use commands.

This supports removing allow_bulk_op_insert entirely, since libmongoc 1.9.0+ already assumes that these legacy write methods are only used for unacknowledged writes.

Comment by Jeremy Mikola [ 04/Apr/19 ]

Repurposing this ticket per kevin.albertson's comment in PHPC-1351: If we can assume that legacy write operations are only applicable to w:0 writes, than we can remove allow_bulk_op_insert, and any other logic for acknowledged legacy write operations altogether. That seems more desirable.

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