Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-564

getLastError() fail randomly

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • legacy-1.0.0
    • API

    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()

      { //each thread call this once at thread startup mongoPtr_ = new mongo::DBClientConnection(); ...}

      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())

      { std::cout << "insert failed" << std::endl; }

      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.

      Attachments

        Activity

          People

            adam.midvidy Adam Midvidy
            Judy.Han Judy Han [X]
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: