Uploaded image for project: 'Couchbase node.js Client Library'
  1. Couchbase node.js Client Library
  2. JSCBC-1108

using consistentWith with query is impossible

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • 4.2.0
    • 4.1.3
    • library
    • None
    • 1

    Description

      CB++ only applies the mutation state if scan consistency is not defined.

      https://github.com/couchbaselabs/couchbase-cxx-client/blob/ab0fee47a28f5d00b678e289929eaea9ba3662ee/core/operations/document_query.cxx#L111-L136

          if (scan_consistency) {
              switch (scan_consistency.value()) {
                  case couchbase::core::query_scan_consistency::not_bounded:
                      body["scan_consistency"] = "not_bounded";
                      break;
                  case couchbase::core::query_scan_consistency::request_plus:
                      check_scan_wait = true;
                      body["scan_consistency"] = "request_plus";
                      break;
              }
          } else if (!mutation_state.empty()) {
              check_scan_wait = true;
              body["scan_consistency"] = "at_plus";
              tao::json::value scan_vectors = tao::json::empty_object;
              for (const auto& token : mutation_state) {
                  auto* bucket = scan_vectors.find(token.bucket_name());
                  if (bucket == nullptr) {
                      scan_vectors[token.bucket_name()] = tao::json::empty_object;
                      bucket = scan_vectors.find(token.bucket_name());
                  }
                  auto& bucket_obj = bucket->get_object();
                  bucket_obj[std::to_string(token.partition_id())] =
                    std::vector<tao::json::value>{ token.sequence_number(), std::to_string(token.partition_uuid()) };
              }
              body["scan_vectors"] = scan_vectors;
          } 

      The SDK always sets a scan consistency even if not defined in the options which makes using consistentWith impossible as CB++ never includes the scan vector in the query request

      https://github.com/couchbase/couchnode/blob/1ccbf734fda2b9e87d414894c131b13ce0cec852/lib/bindingutilities.ts#L131-L148

      export function viewScanConsistencyToCpp(
        mode: ViewScanConsistency | undefined
      ): CppViewScanConsistency {
        // Unspecified is allowed, and means no sync durability.
        if (mode === null || mode === undefined) {
          return binding.view_scan_consistency.not_bounded
        }
        if (mode === ViewScanConsistency.NotBounded) {
          return binding.view_scan_consistency.not_bounded
        } else if (mode === ViewScanConsistency.UpdateAfter) {
          return binding.view_scan_consistency.update_after
        } else if (mode === ViewScanConsistency.RequestPlus) {
          return binding.view_scan_consistency.request_plus
        }
        throw new errs.InvalidArgumentError()
      } 

      Attachments

        For Gerrit Dashboard: JSCBC-1108
        # Subject Branch Project Status CR V

        Activity

          People

            jared.casey Jared Casey
            jake.rawsthorne Jake Rawsthorne
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty