New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct usage of options array on executeBulkWrite #780
Comments
executeBulkWrite
Would you mind registering a CommandSubscriber (following the steps in the APM tutorial) and sharing information from the CommandStartedEvent objects? If you may have multiple commands running in the process, you can use As an aside, if you can capture trace logs (using the For all variations, it'd be best if you used the same insertion data/payload. |
Sorry for the delay. I changed how to generate the insertion payload with the variations and pushed all code to https://github.com/gmsantos/bulkwrite Also added the query listener and tried to dump into a file, but the generated output for |
I disabled the listener in a test and the output of mongodb.debug is smaller. Is that enough for comparison between variations? |
Before I get into an explanation, I'd like to address your previous question:
The documentation on When you were passing Thanks very much for the repository and bundled example scripts. Noting that you were using MongoDB 3.4, I can offer the following explanation: PHP driver 1.3.x uses libmongoc 1.8, which is compatible with server versions up to 3.4. The code path for executing a bulk write is
The above is also discussed in the server manual's documentation for request opcodes. As it relates to your application, you're executing a bulk write (i.e. one or more write operations) with an unacknowledged write concern. This instructs libmongoc to use the legacy wire protocol messages. Instead of batching your 9,000 updates into 9 Given that, any time savings you might have expected with an unacknowledged write concern are forfeited. Note that this is specific to bulk updates and deletes. If you were benchmarking bulk inserts, I expect you'd find that unacknowledged inserts may be faster. Batching between All of that said, MongoDB 3.6 introduced a new In summary, you can do one of two things:
While running your scripts with APM logging, I noticed that each update operation was reporting the full command document (with 9000 update statements) as its own. This effectively produced 9000 times more output than would normally be expected. The bug is a result of libmongoc failing to produce the appropriate synthetic command document when upconverting the legacy Without that bug, APM should have produced less log output than |
Thank you for the explanation. Since mLab doesn't offer mongodb 3.6 yet, I changed the code to use an acknowledged write concern. |
Description
Before version 1.4 I used to execute a bulk write for a heavy process with write concern 0. This process is chunked in some parts to avoid memory size exhaust in big
MongoDB\Driver\BulkWrite
objects.After upgrade to 1.4 driver, I noticed that chunks started to have a big delay in almost an hour, like writeConcern(0) was ignored. Even using the new options array this delay persisted:
But skipping the third argument or using a non associative array eliminated that delay:
What is the correct usage of
$options
argument? Is write concern 0 the default forexecuteBulkWrite
on Manager?Environment
The text was updated successfully, but these errors were encountered: