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
Command does not support writeConcern with wire version 4 #967
Comments
Getting server info with To clarify: Does this mean that the driver cannot set write concerns on MongoDB 3.2? Were my write concerns under 1.4.4 simply being disregarded? I can see this isn't a bug with the driver, but I find it very confusing that upgrading the driver removes functions that appeared to be working. |
The read/write-specific command methods introduced in PHP driver 1.4.0 rely on equivalent functions in libmongoc, which are not intended to be used for the basic insert, update, and delete commands. I've opened PHPC-1350 to ensure that this is noted in the documentation for
With respect to the code you shared above, yes. PHP driver 1.4.x will ignore a
Write concerns have always been supported through If you prefer to use the extension directly, please use Alternatively, specifying a If you'd like additional background information about this issue, read on. The read/write-specific command methods were added to libmongoc specifically to support wrapping drivers, such as PHP. As you know, the PHP extension only provides a basic API for executing bulk writes, queries, and generic commands. The PHP library builds upon that API and provides various helpers for high-level operations (e.g. aggregation, variations of When we introduced That bug was addressed in CDRIVER-2410 for libmongoc 1.9. While mongodb/mongo-c-driver@bd7133d added logic to respect the It was not until libmongoc 1.10 and CDRIVER-2214 that error reporting was introduced when a From the perspective of the PHP driver, this means PHP driver 1.4.x may silently ignore the option. PHP driver 1.5.x uses newer versions of libmongoc (currently 1.11 through 1.13), which is why you see the exception there. |
Thank you for such a comprehensive answer. It's much appreciated. As an aside, I'm only using the driver directly because I migrated a six year old project from the legacy driver. I'll use it for any future projects. |
It sounds like you've already ported the legacy application, but on the off chance the job is still in progress you might find this upgrade guide helpful. For most things, there is a 1:1 mapping between the legacy |
Description
After upgrading the driver to any 1.5.x version, write commands give me an error like this:
"insert" command does not support writeConcern with wire version 4, wire version 5 is required
Version 1.4.4 works fine using v1.9.4 of the C library. Same code, same server.
Environment
MongoDB server version is 3.2.22 using mmapv1 storage engine.
Happens with drivers 1.5.0 through 1.5.3 using bundled versions of libmongoc 1.11.0 through 1.13.0 respectively.
Same results on Mac (built from source) and CentOS (Remi repo).
PHP version is 7.2.16.
Test Script
Expected and Actual Behavior
Throws
MongoDB\Driver\Exception\RuntimeException
: "insert" command does not support writeConcern with wire version 4, wire version 5 is required.The text was updated successfully, but these errors were encountered: