does anyone know a way to update a capped collection in Mongo3.2? I had this working in 2.x where by I updated a collection, and basically removed all its content so I knew it had been processed. This would then age out.
When I do the same in 3.2 I get the following error on the command line.
Cannot change the size of a document in a capped collection: 318 != 40
Here you can see I'm shrinking the document from 318bytes to 40bytes.
Is there a way to do this?
As mentioned in mongodb docs
Changed in version 3.2.
If an update or a replacement operation changes the document size, the operation will fail.
https://docs.mongodb.com/manual/core/capped-collections/
So your operation is changing the size of the capped collection, which is not allowed in mongodb 3.2+
Shrinking a document in a capped collection is no longer allowed in 3.2. I did not find anything related to this in the documentation, but there is a rationale at https://jira.mongodb.org/browse/SERVER-20529 (basicalling shrinking document cannot be rolled back)
Your only option is to find a same-size update, for example update a boolean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With