Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Crashes with "invalid memory operation" when inserting into mongo collection #1707
I'm getting this error in my applicaton:
This happens when saving arrays about 1000 structs long into a mongo using
Minimal example to reproduce this issue:
The larger struct, the shorter array you need to cause a crash.
Any ideas what this might be caused by, and how to fix it?
Unfortunately it's hard to tell the root cause for the invalid memory operation error without a call stack, but the original trigger seems to be that the MongoDB server closes the connection. The reason appears to be that you are running into a hard limit there: https://docs.mongodb.com/manual/reference/limits/#Write-Command-Operation-Limit-Size
I'll try to reproduce the invalid memory operation error later when I get some time.
The 1000 operations limit is on the server side, and it is normally hidden from the app by a driver. See this SO discussion for details http://stackoverflow.com/questions/24237887/what-is-mongodb-batch-operation-max-size
referenced this issue
Mar 8, 2017
@s-ludwig sorry for replying so late. While splitting the array into 1000-element chunks does help, I don't think this is the cause of the crash. The minimal example above executes successfully with 100000 elements, but crashes with 1 million elements. So how come an array of 100k elements can be inserted regardless of the 1000-operation limit?
Good question. Did you verify that all 100k elements are actually in the database after the operation?
I just used the code above to reproduce this locally and these are the current findings: