[SERVER-22218] Push opeartion failed if push and upsert for same document were built into same BulkOperation execution Created: 18/Jan/16  Updated: 14/Apr/16  Resolved: 04/Feb/16

Status: Closed
Project: Core Server
Component/s: Concurrency, Performance, Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: gabriel.wang Assignee: Wan Bachtiar
Resolution: Incomplete Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 3.0.5
C++ driver: 1.0.1
OS: centos 7


Issue Links:
Duplicate
Operating System: Linux
Steps To Reproduce:

BulkOperationBuilder p_builder
p_builder.find(queryObj).upsert().updateOne(BSON("$set"<<bsonObj_1));
p_builder.find(queryObj).update(BSON("$push"<<bsonObj_2));

p_builder.execute()

If both query hit same document, the push operation didn't create the array correctly.

If move push operation away from bulkOperationBuilder and run it in the non-bulk mode, the array field was created correctly.
Moreover, even push operation failed in the bulkOpeation mode, there is no exception raised for the bulkOperation.execute().

Participants:

 Description   

Two separated opeartion: push and upsert were built in same BulkOperation.
if two operation will operate on same document, it will cause the push operation failed.



 Comments   
Comment by Wan Bachtiar [ 04/Feb/16 ]

Hi Gabriel,

We haven’t heard back from you for some time, so I’m going to mark this ticket as resolved.
If this is still an issue for you, please feel free to re-open the ticket and provide additional information.

Regards,
Wan.

Comment by Wan Bachtiar [ 19/Jan/16 ]

Hi Gabriel,

I noticed (from your google groups thread) that you are using WiredTiger storage engine. This behaviour may be caused by SERVER-21275, which was fixed in v3.0.8.
Could you please upgrade to v3.0.8 and try again ? See if that resolves the issue that you are seeing.

Thanks,
Wan.

Comment by gabriel.wang [ 19/Jan/16 ]

Hi Wan,

Thanks for your prompt response.

I thought this issue related to server because the most work of bulk operation happen on server side.

As you mentioned about the bulkOpereation mode and the real order of $push and $set operation.
In my project, I have set the bulk Operation as ordered mode when I initialize it by call:

BulkOperationBuilder bulk = db_conn_.initializeOrderedBulkOp(db_collection_ns_);

According to the calling sequence, the $push is the last one operation on a given document. It's impossible that a $push happen before a $set for a specific document. Moreover, the $set and $push performed on different fields of a document.

This issue occurs only when very heavy writing operation on a collection, and about 1/1000 $push operation failed, and most of $push performed correctly.

Thanks for your help in advance.

Comment by Wan Bachtiar [ 19/Jan/16 ]

Hi Gabriel,

I have tested the BulkOperationBuilder for mongo-cxx-driver legacy v1.0.1. It behaves as expected.

In your case, you may want to specify whether you would like an ordered or unordered bulk operation. You can specify this option with either the initialisation methods or the constructor. See BulkOperationBuilder class reference for more info.

Example of using the constructor:

mongo::BulkOperationBuilder p_builder(conn, collection_namespace, ordered_bool);

If you are using an unordered bulk operation, and when the $push operation is being executed first before the $set, the $set will overwrite $push. This may appear that the $push operation has not been performed correctly.

Note that the latest stable version of mongo-cxx-legacy driver is currently v1.1.0

Also please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB Server. If you have any follow-up questions on bulk operations ordering, please post on the mongodb-user group

Kind regards,

Wan.

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