I am developing an application basing on mongodb c++ driver.
When I call insert_many(), if the documents are too large, the underlayer of the c driver invokes c standard api ‘abort()’ and so my application exits sliently.
I saw c++ could throw c++ exception when calling insert_many() , but obvisouly it doesn’t cover this case.
But I do need a chance to run my application code when abort() is invoked.
So my question is: #1 does mongodb c++ driver provides a way to handle this gracefully? If so, how? #2 is there a recommended way to handle this case? #3 Is it necessary to handle this in my application layer? for example, use SIGABRT mechanism. I don’t like this way if #1 or #2 could work.
When I call insert_many(), if the documents are too large, the underlayer of the c driver invokes c standard api ‘abort()’ and so my application exits sliently.
I was unable to reproduce with this example. It calls insert_many() with a large document and results in an exception with the message object to insert too large. size in bytes: 16777258, max size: 16777216.
Some additional information may help to reproduce:
How is insert_many() called? Can you provide a code snippet?
What server version was used? The error I got comes from the server. I tested with MongoDB server 7.0.0.
What version of the C and C++ drivers was used? I tested with C driver 1.26.2 and C++ driver 3.9.0.
How is insert_many() called? Can you provide a code snippet?
My application reads documents from a queue and writes the documents together by calling insert_many. No special configurations.
What server version was used? The error I got comes from the server. I tested with MongoDB server 7.0.0.
7.0.
What version of the C and C++ drivers was used? I tested with C driver 1.26.2 and C++ driver 3.9.0.
mongo-c-driver_x64-windows: 1.24.3
mongo-cxx-driver_x64-windows: 3.8.0
Thank you for the additional information. I can reproduce the error with C driver 1.23.2 (example). However, this did not reproduce when testing with C driver 1.25.1. I expect this is fixed by CDRIVER-4772. Try upgrading to C driver 1.25.1 or later.
One general question, currently I am using try catch to handle MongoDB driver exceptions. Should I handle the abort() in my application? Because there are might be somewhere else I could trigger ‘abort()’.