mongo-php-driver: BulkWrite error :: '$set' is empty. You must specify a field like so: {$set: {: ...}}
Hey,
We recently switched our production server to PHP7:
$ php -v
PHP 7.0.4-7+deb.sury.org~trusty+2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
And using the new Mongodb driver (1.1.5).
We noticed that sometimes there’s a weird behaviour but unfortunately I can’t reproduce it yet (it’s quite random but for sure happens only on PHP7 servers). When I run the code on dev it works perfectly. I am seeing the following error:
BulkWrite error :: '$set' is empty. You must specify a field like so: {$set: {<field>: ...}}
app/vendor/composer/mongodb/mongodb/src/Operation/Update.php (121)
MongoDB\Driver\Server::executeBulkWrite
File: app/vendor/composer//mongodb-odm-light/lib/Doctrine/MongoDB/Collection.php in line 1397
Method: MongoCollection->update
Parameter: [['_id' => 'req-a10cd3c3-8485-4d21-9928-239379251472'], ['$set' => ['creatorHostname' => 'prod.cloud.net', 'handledAt' => MongoDate]], ['upsert' => true]]
File: app/vendor/composer/alcaeus/mongo-php-adapter/lib/Mongo/MongoCollection.php in line 387
Method: Alcaeus\MongoDbAdapter\ExceptionConverter::toLegacy
Parameter: [MongoDB\Driver\Exception\BulkWriteException]
As you can see, the $set
parameter is definitely not empty. I have tried to debug a bit but still can’t figure this issue.
I am not sure if this bug should be here so I opened it also under mongo-php-adapter’s repository: https://github.com/alcaeus/mongo-php-adapter/issues/93
The moment I have a way to reproduce it, will attach a code snippet but maybe in the meanwhile there’s something I have missed.
Thank you
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 28 (12 by maintainers)
It was a bug in the APCu extension.
We tested again with the updated and fixed APCu extension and the issue does not appear anymore so it seems APCu was the culprit, though it is still a bit strange since the BsonDocuments were never stored or read from APCu.
Nonetheless, I think we can close the issue 😃
This will take a couple of days until we can test this. I’ll keep you updated.