Uploaded image for project: 'C++ Couchbase Client'
  1. C++ Couchbase Client
  2. CXXCBC-57

KV request hangs if couchbase restarted on all but one node

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.0-beta
    • 1.0.0-beta
    • None
    • 1
    • SDK02: CB++ and Query Error

    Description

      1. Create 4 node cluster with kv service
      2. Run a kv operation in a loop (e.g. upsert)
      3. Stop couchbase on nodes 2-4
      4. Wait 5 seconds
      5. Restart couchbase on nodes 2-4
      6. Once all the nodes are reachable again the kv operation will hang (doesn't return a success or timeout error)

      #include <couchbase/cluster.hxx>
      #include <couchbase/logger/logger.hxx>
       
      int main()
      {
        couchbase::logger::create_console_logger();
        couchbase::logger::set_log_levels(spdlog::level::trace);
       
        asio::io_context io{};
        couchbase::cluster cluster(io);
        auto connstr = couchbase::utils::parse_connection_string("couchbase://172.23.111.128");
        couchbase::cluster_credentials auth{};
        auth.username = "Administrator";
        auth.password = "password";
        auto io_thread = std::thread([&io]()
                                     { io.run(); });
        auto origin = couchbase::origin(auth, connstr);
       
        {
          auto barrier = std::make_shared<std::promise<std::error_code>>();
          auto f = barrier->get_future();
          cluster.open(origin, [barrier](std::error_code ec) mutable
                       { barrier->set_value(ec); });
          auto rc = f.get();
        }
       
        {
          auto barrier = std::make_shared<std::promise<std::error_code>>();
          auto f = barrier->get_future();
          cluster.open_bucket("default", [barrier](std::error_code ec) mutable
                              { barrier->set_value(ec); });
          auto rc = f.get();
        }
       
        while (true)
        {
          {
            couchbase::document_id id("default", "_default", "_default", "key");
            std::string value{"value"};
            couchbase::operations::upsert_request req{id, value};
            auto barrier = std::make_shared<std::promise<couchbase::operations::upsert_response>>();
            auto f = barrier->get_future();
            cluster.execute(req, [barrier](couchbase::operations::upsert_response resp)
                            { barrier->set_value(std::move(resp)); });
            f.get();
          }
        }
       
        {
          auto barrier = std::make_shared<std::promise<void>>();
          auto f = barrier->get_future();
          cluster.close([barrier]()
                        { barrier->set_value(); });
          f.get();
        }
       
        io_thread.join();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            avsej Sergey Avseyev
            jake.rawsthorne Jake Rawsthorne
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes