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

SDK hangs at cluster::connect when a custom metadata collection is specified

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0.0-dp.14
    • None
    • transactions
    • None

    Description

      When calling cluster::connect, it invokes the constructor of couchbase::cluster from the callback of core.open, which is running on an IO thread: https://github.com/couchbaselabs/couchbase-cxx-client/blob/main/core/impl/cluster.cxx#L381

      The constructor of couchbase::cluster, then invokes the constructor of
      couchbase::core::transactions::transactions, which attempts to open the bucket of the custom metadata collection, and blocks until the bucket has been opened: https://github.com/couchbaselabs/couchbase-cxx-client/blob/main/core/transactions/transactions.cxx#L48-L66
      As open_bucket here is called from within an IO thread (callback of core.open) it will hang if only 1 IO thread is configured, as there are no available IO threads (as the only available IO thread is occupied by the callback of core.open which will never return as that requires the transactions object to be constructed)

      To reproduce:

      int
      main()
      {
          couchbase::core::logger::create_console_logger();
          couchbase::core::logger::set_log_levels(couchbase::core::logger::level::trace);
       
          asio::io_context io;
          auto guard = asio::make_work_guard(io);
          std::thread io_thread([&io]() { io.run(); });
       
          auto options = couchbase::cluster_options("Administrator", "password");
          options.transactions().metadata_collection(couchbase::transactions::transaction_keyspace{ "default", couchbase::scope::default_name, couchbase::collection::default_name });
          auto [cluster, ec] = couchbase::cluster::connect(io, "couchbase://127.0.0.1", options).get();
       
          cluster.close();
          guard.reset();
          io_thread.join();
       
          return 0;
      } 

      Attachments

        Issue Links

          For Gerrit Dashboard: CXXCBC-462
          # Subject Branch Project Status CR V

          Activity

            People

              Dimitris.Christodoulou Dimitris Christodoulou
              Dimitris.Christodoulou Dimitris Christodoulou
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes