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

The first time a document is inserted in a collection that does not exist, the driver crashes

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.0
    • Component/s: Implementation
    • Labels:
      None
    • Environment:
      Linux Mint 64bit. MongoDB running in Docker-CE.

      My application writes new documents to the DB every time there is a new transaction available. When my program runs for the first time and the destination collection does not exist, the `insert_one` operation does not return for a while. After a number of seconds, it times out with the following exception (a good portion of the log is from my application):

       

      /opt/libs/mongo-c-driver-1.13.1/src/libmongoc/src/mongoc/mongoc-socket.c:594 mongoc_socket_errno(): precondition failed: sock
      Caught signal 6 (SIGABRT)
            71c283: terminate called after throwing an instance of 'mongocxx::v_noabi::bulk_write_exception'
        what():  Failed to send "insert" command with database "eyeris": Failed to read 27026 bytes: socket error or timeout: generic server error
      Caught signal 6 (SIGABRT)
            71c283: eyemachine::actor_launchpad::Launchpad::abortHandler(int, siginfo_t*, void*) launchpad.cpp:152
      7fa009bd3890: eyemachine::actor_launchpad::Launchpad::abortHandler(int, siginfo_t*, void*) launchpad.cpp:152
      7fa009bd3890: funlockfile ??:0
      7fa007ca9e97: funlockfile ??:0
      7fa007ca9e97: gsignal ??:0
      7fa007cab801: gsignal ??:0
      7fa007cab801: abort ??:0
      7fa0068210c1: abort ??:0
      7fa0083008b7: mongoc_socket_errno ??:0
      7fa006823e9f: UNKNOWN 0x141
      7fa008306a06: _mongoc_stream_socket_readv ??:0
      7fa006822cbd: std::rethrow_exception(std::__exception_ptr::exception_ptr) ??:0
      7fa008306a41: mongoc_stream_read ??:0
      7fa0067f52de: std::terminate() ??:0
      7fa008306c74: _mongoc_buffer_append_from_stream ??:0
      7fa0067fc945: __cxa_throw ??:0
      7fa00b1a3fd2: mongoc_cluster_run_opmsg ??:0
      7fa0067fc3ef: void mongocxx::v_noabi::throw_exception<mongocxx::v_noabi::bulk_write_exception>(bsoncxx::v_noabi::document::value, _bson_error_t const&) ??:0
      7fa00b1a3931: mongoc_cluster_run_command_monitored ??:0
      7fa00682f6a7: mongocxx::v_noabi::bulk_write::execute() const ??:0
      7fa00b1ab28a: _mongoc_write_command_execute_idl ??:0
      7fa00682f0ac: mongocxx::v_noabi::collection::_insert_one(mongocxx::v_noabi::client_session const*, bsoncxx::v_noabi::view_or_value<bsoncxx::v_noabi::document::view, bsoncxx::v_noabi::document::value>, mongocxx::v_noabi::options::insert const&) ??:0
      7fa00b1ab7c3: _mongoc_write_command_execute ??:0
      7fa0067f6dfd: mongocxx::v_noabi::collection::insert_one(bsoncxx::v_noabi::view_or_value<bsoncxx::v_noabi::document::view, bsoncxx::v_noabi::document::value>, mongocxx::v_noabi::options::insert const&) ??:0
      7fa00c387265: mongoc_bulk_operation_execute ??:0
      7fa00b1a3909: eyemachine::db::RecordingsCollection::store(std::shared_ptr<eyelib::experiment::RecordingInfoCard> const&) ??:0
            818554: mongocxx::v_noabi::bulk_write::execute() const ??:0
      7fa00b1ab28a: mongocxx::v_noabi::collection::_insert_one(mongocxx::v_noabi::client_session const*, bsoncxx::v_noabi::view_or_value<bsoncxx::v_noabi::document::view, bsoncxx::v_noabi::document::value>, mongocxx::v_noabi::options::insert const&) ??:0
      7fa00b1ab7c3: mongocxx::v_noabi::collection::insert_one(bsoncxx::v_noabi::view_or_value<bsoncxx::v_noabi::document::view, bsoncxx::v_noabi::document::value>, mongocxx::v_noabi::options::insert const&) ??:0
      7fa00c386459: eyemachine::db::LogCollection::store(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, eyelib::time::Timestamp const&, eyelib::logging::log_level_e, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ??:0
            6a2327: eyemachine::actor_habitat::Habitat::storeInLogDB(std::shared_ptr<eyemachine::eimp::LogMessage>) habitat.hpp:171
            69deca: eyemachine::actor_workspace::Workspace::completeJob() workspace.cpp:312
            818450: eyemachine::actor_habitat::Habitat::messageLog(std::shared_ptr<eyelib::messaging::MessageBase>) habitat.cpp:206
            715fca: void std::__invoke_impl<void, void (eyemachine::actor_habitat::Habitat::*&)(std::shared_ptr<eyelib::messaging::MessageBase>), eyemachine::actor_habitat::Habitat*&, std::shared_ptr<eyemachine::messaging::EMPMessageBase> >(std::__invoke_memfun_deref, void (eyemachine::actor_habitat::Habitat::*&)(std::shared_ptr<eyelib::messaging::MessageBase>), eyemachine::actor_habitat::Habitat*&, std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&) invoke.h:73
            715e87: eyemachine::actor_workspace::Workspace::singleStep() workspace.cpp:280
            8300a9: std::__invoke_result<void (eyemachine::actor_habitat::Habitat::*&)(std::shared_ptr<eyelib::messaging::MessageBase>), eyemachine::actor_habitat::Habitat*&, std::shared_ptr<eyemachine::messaging::EMPMessageBase> >::type std::__invoke<void (eyemachine::actor_habitat::Habitat::*&)(std::shared_ptr<eyelib::messaging::MessageBase>), eyemachine::actor_habitat::Habitat*&, std::shared_ptr<eyemachine::messaging::EMPMessageBase> >(void (eyemachine::actor_habitat::Habitat::*&)(std::shared_ptr<eyelib::messaging::MessageBase>), eyemachine::actor_habitat::Habitat*&, std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&) invoke.h:95
            715de8: void std::_Bind<void (eyemachine::actor_habitat::Habitat::*(eyemachine::actor_habitat::Habitat*, std::_Placeholder<1>))(std::shared_ptr<eyelib::messaging::MessageBase>)>::__call<void, std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&, 0ul, 1ul>(std::tuple<std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&>&&, std::_Index_tuple<0ul, 1ul>) functional:467
            715d3d: eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::internalMain() worker.hpp:203
            8309a1: void std::_Bind<void (eyemachine::actor_habitat::Habitat::*(eyemachine::actor_habitat::Habitat*, std::_Placeholder<1>))(std::shared_ptr<eyelib::messaging::MessageBase>)>::operator()<std::shared_ptr<eyemachine::messaging::EMPMessageBase>, void>(std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&) functional:549
            715b72: std::_Function_handler<void (std::shared_ptr<eyemachine::messaging::EMPMessageBase>), std::_Bind<void (eyemachine::actor_habitat::Habitat::*(eyemachine::actor_habitat::Habitat*, std::_Placeholder<1>))(std::shared_ptr<eyelib::messaging::MessageBase>)> >::_M_invoke(std::_Any_data const&, std::shared_ptr<eyemachine::messaging::EMPMessageBase>&&) std_function.h:318
            71942b: void std::__invoke_impl<void, void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*>(std::__invoke_memfun_deref, void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*&&)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*&&) invoke.h:73
            8308b2: std::function<void (std::shared_ptr<eyemachine::messaging::EMPMessageBase>)>::operator()(std::shared_ptr<eyemachine::messaging::EMPMessageBase>) const std_function.h:706
            71921c: std::__invoke_result<void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*>::type std::__invoke<void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*>(void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*&&)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*&&) invoke.h:95
            830872: eyelib::CallbackMap<unsigned int, std::shared_ptr<eyemachine::messaging::EMPMessageBase> >::callback(unsigned int, std::shared_ptr<eyemachine::messaging::EMPMessageBase>) callback_map.hpp:34
            6a1707: eyemachine::platform::Engine<eyemachine::actor_habitat::Habitat, eyemachine::actor_habitat::HabitatConfiguration>::processInternalMessages() engine.hpp:316
            69e49b: _ZNSt6thread8_InvokerISt5tupleIJMN6eyelib8platform6WorkerIN10eyemachine15actor_workspace9WorkspaceEEEFvvEPS8_EEE9_M_invokeIJLm0ELm1EEEEDTclsr3stdE8__invokespcl10_S_declvalIXT_EEEEESt12_Index_tupleIJXspT_EEE thread:234
            830825: eyemachine::actor_habitat::Habitat::singleStep() habitat.cpp:163
            7171a9: eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::internalMain() worker.hpp:203
            717aa1: std::thread::_Invoker<std::tuple<void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*> >::operator()() thread:243
            8305f9: void std::__invoke_impl<void, void (eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::*)(), eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>*>(std::__invoke_memfun_deref, void (eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::*&&)(), eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>*&&) invoke.h:73
            7179b2: std::__invoke_result<void (eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::*)(), eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>*>::type std::__invoke<void (eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::*)(), eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>*>(void (eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>::*&&)(), eyelib::platform::Worker<eyemachine::actor_habitat::Habitat>*&&) invoke.h:95
            717972: std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>::*)(), eyelib::platform::Worker<eyemachine::actor_workspace::Workspace>*> > >::_M_run() thread:186
      7fa00833157f: std::error_code::default_error_condition() const ??:0
      7fa009bc86db: start_thread ??:0
      7fa007d8c88f: clone ??:0
      Caught signal 11 (SIGSEGV)
      

      If I look into the DB after the exception, the collection exists and the first document is in there. Launching again my application does not produce the error anymore. If I remove the collection and try again, I can reproduce the exception again.

       

       

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            fabrizio@santinidesigns.com Fabrizio Santini
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: