Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
legacy-1.0.0
Description
I have an application - a threadpool with each worker thread maintaining it's own connection, after insert (bulk) the subsequent getLastError() call randomly fail. Here is the relavant code snippet for each worker thread:
static _thread mongo::DBClientConnection *mongoPtr;
...
bool event_loader::threadSpecificInit()
void event_loader::handleInput() {
//each thread run this in a loop
try {
//build bulk_data
......
mongoPtr_->insert("event_test.collection1", bulk_data);
if (!(mongoPtr_->getLastError()).empty())
catch (const MtxUtil::Exception& exc)
{ std::cout << "Caught an exception during getLastError.\n" << "Exception's what()=" << exc.what() << std::endl; }catch (...)
{ std::cout << "Caught an unknown exception during getLastError." << std::endl; }Without calling getLastError(), the program seems works fine. After adding getLastError() logic, the program works sometimes, but fails some other time, once it fails it continues to fail.
Following is the output for failed case:
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.
Caught an unknown exception during getLastError.