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

Tail cursor block thread after network switching

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Minor - P4 Minor - P4
    • None
    • 3.1.1
    • None
    • None
    • debian 8.6

    Description

      Hello! When I run tail cursor in while loop and disable network adapter for a few minutes the thread that reading tail cursor become blocked. Version is 3.1.1 with custom update for tail cursors work

      mongocxx::stdx::optional<mongocxx::pool::entry> sc = try_get_connection_from_pool(connection_name);
          if (sc == mongocxx::stdx::nullopt) throw std::runtime_error("cant get connection from pool");
          mongocxx::client* conn = sc->get();
       
          try
          {
              auto db = (*conn)[connection_name];
              mongocxx::collection coll = db[collection];
       
              bsoncxx::document::value f = bsoncxx::from_json(json);
       
              mongocxx::options::find options;
              options.cursor_type(mongocxx::cursor::type::k_tailable_await);
       
              mongocxx::cursor cursor = coll.find(f.view(), options);
       
              while(is_running.load(std::memory_order_acquire))
              {
                  /*if(cursor.begin() == cursor.end())
                  {
                      std::this_thread::sleep_for(std::chrono::seconds(1));
                      continue;
                  }*/
       
                  //here its blocked
                  for(auto&& doc : cursor)
                  {
                      mongo::db::fetcher st(doc);
                      callback(&st);
                  }
       
                  if (callback_run) callback_run();
              }
          }
          catch(std::exception& ex)
          {
              throw ex;
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            denbip Denis Bip
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: