couchbase 4.4.6 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +79 -165
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +14 -3
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/cmake/Profiler.cmake +15 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_address.cxx +55 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_address.hxx +39 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +791 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_meter.hxx +200 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +895 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +59 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +77 -35
- package/deps/couchbase-cxx-client/core/bucket.hxx +17 -10
- package/deps/couchbase-cxx-client/core/cluster.cxx +56 -17
- package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +27 -0
- package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +36 -0
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +13 -0
- package/deps/couchbase-cxx-client/core/collections_component.cxx +7 -5
- package/deps/couchbase-cxx-client/core/http_component.cxx +6 -0
- package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +10 -0
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/error.cxx +22 -6
- package/deps/couchbase-cxx-client/core/impl/error.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/logger.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/replica_utils.cxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
- package/deps/couchbase-cxx-client/core/impl/transaction_get_multi_spec.cxx +30 -0
- package/deps/couchbase-cxx-client/core/impl/transaction_op_error_category.cxx +2 -0
- package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +6 -6
- package/deps/couchbase-cxx-client/core/io/http_command.hxx +35 -11
- package/deps/couchbase-cxx-client/core/io/http_session.cxx +10 -0
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +4 -0
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +87 -35
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +41 -2
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +52 -19
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +3 -0
- package/deps/couchbase-cxx-client/core/logger/logger.cxx +46 -0
- package/deps/couchbase-cxx-client/core/logger/logger.hxx +41 -1
- package/deps/couchbase-cxx-client/core/management/bucket_settings.hxx +1 -0
- package/deps/couchbase-cxx-client/core/management/bucket_settings_json.hxx +4 -0
- package/deps/couchbase-cxx-client/core/meta/features.hxx +32 -0
- package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +9 -9
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +10 -2
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in.cxx +4 -0
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +14 -2
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +4 -0
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.cxx +4 -0
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -10
- package/deps/couchbase-cxx-client/core/operations/http_noop.cxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_create.cxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_update.cxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +3 -2
- package/deps/couchbase-cxx-client/core/origin.cxx +25 -5
- package/deps/couchbase-cxx-client/core/origin.hxx +18 -24
- package/deps/couchbase-cxx-client/core/platform/random.cc +6 -3
- package/deps/couchbase-cxx-client/core/platform/random.h +2 -2
- package/deps/couchbase-cxx-client/core/protocol/cmd_mutate_in.hxx +9 -0
- package/deps/couchbase-cxx-client/core/timeout_defaults.hxx +4 -0
- package/deps/couchbase-cxx-client/core/topology/configuration.cxx +10 -13
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +14 -15
- package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +6 -0
- package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +22 -2
- package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +25 -7
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +723 -245
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +91 -12
- package/deps/couchbase-cxx-client/core/transactions/exceptions.cxx +5 -0
- package/deps/couchbase-cxx-client/core/transactions/exceptions.hxx +20 -0
- package/deps/couchbase-cxx-client/core/transactions/exceptions_fmt.hxx +3 -0
- package/deps/couchbase-cxx-client/core/transactions/forward_compat.cxx +71 -6
- package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +45 -59
- package/deps/couchbase-cxx-client/core/transactions/get_multi_orchestrator.cxx +616 -0
- package/deps/couchbase-cxx-client/core/transactions/get_multi_orchestrator.hxx +61 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.cxx +8 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +16 -5
- package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +12 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +13 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/transaction_fields.hxx +1 -0
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +277 -96
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +28 -76
- package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -0
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_mode.hxx +28 -0
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +72 -0
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_multi_result.hxx +67 -0
- package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +10 -0
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +8 -3
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +7 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
- package/deps/couchbase-cxx-client/core/utils/url_codec.cxx +26 -0
- package/deps/couchbase-cxx-client/core/utils/url_codec.hxx +11 -0
- package/deps/couchbase-cxx-client/core/websocket_codec.cxx +647 -0
- package/deps/couchbase-cxx-client/core/websocket_codec.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +70 -6
- package/deps/couchbase-cxx-client/couchbase/application_telemetry_options.hxx +124 -0
- package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +9 -0
- package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +17 -0
- package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/logger.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/management/bucket_settings.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/query_options.hxx +70 -6
- package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +29 -5
- package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +24 -7
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +112 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_result.hxx +105 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
- package/dist/analyticsindexmanager.d.ts +1 -0
- package/dist/binarycollection.d.ts +1 -0
- package/dist/binding.d.ts +82 -38
- package/dist/binding.js +14 -7
- package/dist/bindingutilities.d.ts +16 -4
- package/dist/bindingutilities.js +233 -31
- package/dist/cluster.d.ts +39 -0
- package/dist/cluster.js +21 -3
- package/dist/collection.d.ts +20 -1
- package/dist/collection.js +13 -0
- package/dist/errorcontexts.d.ts +24 -0
- package/dist/errorcontexts.js +12 -6
- package/dist/generaltypes.d.ts +16 -0
- package/dist/generaltypes.js +18 -1
- package/dist/httpexecutor.d.ts +1 -2
- package/dist/httpexecutor.js +0 -9
- package/dist/streamablepromises.d.ts +25 -7
- package/dist/streamablepromises.js +32 -7
- package/dist/transactions.d.ts +239 -1
- package/dist/transactions.js +316 -2
- package/dist/transcoders.d.ts +1 -0
- package/dist/utilities.d.ts +1 -0
- package/package.json +24 -24
- package/src/connection.cpp +34 -4
- package/src/constants.cpp +124 -0
- package/src/jstocbpp_autogen.hpp +22 -8
- package/src/jstocbpp_transactions.hpp +76 -2
- package/src/transaction.cpp +101 -0
- package/src/transaction.hpp +5 -0
- package/tools/gen-bindings-js.js +2 -1
- package/tools/gen-bindings-json.py +28 -3
@@ -19,6 +19,7 @@
|
|
19
19
|
|
20
20
|
#include <couchbase/build_config.hxx>
|
21
21
|
|
22
|
+
#include "core/app_telemetry_meter.hxx"
|
22
23
|
#include "core/config_listener.hxx"
|
23
24
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
24
25
|
#include "core/columnar/bootstrap_notification_subscriber.hxx"
|
@@ -74,6 +75,11 @@ public:
|
|
74
75
|
meter_ = std::move(meter);
|
75
76
|
}
|
76
77
|
|
78
|
+
void set_app_telemetry_meter(std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter)
|
79
|
+
{
|
80
|
+
app_telemetry_meter_ = std::move(app_telemetry_meter);
|
81
|
+
}
|
82
|
+
|
77
83
|
auto configuration_capabilities() const -> configuration_capabilities
|
78
84
|
{
|
79
85
|
std::scoped_lock config_lock(config_mutex_);
|
@@ -108,8 +114,11 @@ public:
|
|
108
114
|
void update_config(topology::configuration config) override
|
109
115
|
{
|
110
116
|
{
|
111
|
-
std::scoped_lock config_lock(config_mutex_, sessions_mutex_);
|
117
|
+
std::scoped_lock config_lock(config_mutex_, sessions_mutex_, next_index_mutex_);
|
112
118
|
config_ = std::move(config);
|
119
|
+
if (!config_.nodes.empty() && next_index_ >= config_.nodes.size()) {
|
120
|
+
next_index_ = 0;
|
121
|
+
}
|
113
122
|
for (auto& [type, sessions] : idle_sessions_) {
|
114
123
|
sessions.remove_if([&opts = options_, &cfg = config_](const auto& session) {
|
115
124
|
return session && !cfg.has_node(opts.network,
|
@@ -203,7 +212,7 @@ public:
|
|
203
212
|
std::uint16_t port = node.port_or(options_.network, type, options_.enable_tls, 0);
|
204
213
|
if (port != 0) {
|
205
214
|
const auto& hostname = node.hostname_for(options_.network);
|
206
|
-
auto session = create_session(type, credentials, hostname, port);
|
215
|
+
auto session = create_session(type, credentials, hostname, port, node.node_uuid);
|
207
216
|
if (session->is_connected()) {
|
208
217
|
std::scoped_lock lock(sessions_mutex_);
|
209
218
|
busy_sessions_[type].push_back(session);
|
@@ -217,11 +226,17 @@ public:
|
|
217
226
|
request,
|
218
227
|
tracer_,
|
219
228
|
meter_,
|
229
|
+
app_telemetry_meter_,
|
220
230
|
options_.default_timeout_for(request.type),
|
221
231
|
dispatch_timeout_);
|
222
232
|
#else
|
223
233
|
auto cmd = std::make_shared<operations::http_command<operations::http_noop_request>>(
|
224
|
-
ctx_,
|
234
|
+
ctx_,
|
235
|
+
request,
|
236
|
+
tracer_,
|
237
|
+
meter_,
|
238
|
+
app_telemetry_meter_,
|
239
|
+
options_.default_timeout_for(request.type));
|
225
240
|
#endif
|
226
241
|
|
227
242
|
cmd->start([start = std::chrono::steady_clock::now(),
|
@@ -283,6 +298,7 @@ public:
|
|
283
298
|
error });
|
284
299
|
self->check_in(type, cmd->session_);
|
285
300
|
});
|
301
|
+
|
286
302
|
cmd->set_command_session(session);
|
287
303
|
if (!session->is_connected()) {
|
288
304
|
connect_then_send(session, cmd, {}, true);
|
@@ -300,10 +316,13 @@ public:
|
|
300
316
|
const std::string& undesired_node = {})
|
301
317
|
-> std::pair<std::error_code, std::shared_ptr<http_session>>
|
302
318
|
{
|
319
|
+
std::string node_uuid{};
|
320
|
+
|
303
321
|
if (preferred_node.empty() && !undesired_node.empty()) {
|
304
|
-
auto [hostname, port] = pick_random_node(type, undesired_node);
|
322
|
+
auto [hostname, port, uuid] = pick_random_node(type, undesired_node);
|
305
323
|
if (port != 0) {
|
306
324
|
preferred_node = fmt::format("{}:{}", hostname, port);
|
325
|
+
node_uuid = uuid;
|
307
326
|
}
|
308
327
|
}
|
309
328
|
|
@@ -343,7 +362,7 @@ public:
|
|
343
362
|
break;
|
344
363
|
}
|
345
364
|
} else {
|
346
|
-
session = create_session(type, credentials, hostname, port);
|
365
|
+
session = create_session(type, credentials, hostname, port, node_uuid);
|
347
366
|
break;
|
348
367
|
}
|
349
368
|
}
|
@@ -355,12 +374,12 @@ public:
|
|
355
374
|
session.reset();
|
356
375
|
}
|
357
376
|
if (!session) {
|
358
|
-
auto [hostname, port] =
|
377
|
+
auto [hostname, port, uuid] =
|
359
378
|
preferred_node.empty() ? next_node(type) : lookup_node(type, preferred_node);
|
360
379
|
if (port == 0) {
|
361
380
|
return { errc::common::service_not_available, nullptr };
|
362
381
|
}
|
363
|
-
session = create_session(type, credentials, hostname, port);
|
382
|
+
session = create_session(type, credentials, hostname, port, uuid);
|
364
383
|
}
|
365
384
|
if (session->is_connected()) {
|
366
385
|
busy_sessions_[type].push_back(session);
|
@@ -472,13 +491,19 @@ public:
|
|
472
491
|
request,
|
473
492
|
tracer_,
|
474
493
|
meter_,
|
494
|
+
app_telemetry_meter_,
|
475
495
|
options_.default_timeout_for(request.type),
|
476
496
|
dispatch_timeout_);
|
477
497
|
cmd->start([self = shared_from_this(), cmd, handler = std::forward<Handler>(handler)](
|
478
498
|
error_union err, io::http_response&& msg) mutable {
|
479
499
|
#else
|
480
500
|
auto cmd = std::make_shared<operations::http_command<Request>>(
|
481
|
-
ctx_,
|
501
|
+
ctx_,
|
502
|
+
request,
|
503
|
+
tracer_,
|
504
|
+
meter_,
|
505
|
+
app_telemetry_meter_,
|
506
|
+
options_.default_timeout_for(request.type));
|
482
507
|
cmd->start([self = shared_from_this(), cmd, handler = std::forward<Handler>(handler)](
|
483
508
|
std::error_code ec, io::http_response&& msg) mutable {
|
484
509
|
#endif
|
@@ -571,15 +596,15 @@ public:
|
|
571
596
|
|
572
597
|
// stop this session and create a new one w/ new hostname + port
|
573
598
|
session->stop();
|
574
|
-
auto [hostname, port] = preferred_node.empty()
|
575
|
-
|
576
|
-
|
599
|
+
auto [hostname, port, node_uuid] = preferred_node.empty()
|
600
|
+
? self->next_node(session->type())
|
601
|
+
: self->lookup_node(session->type(), preferred_node);
|
577
602
|
if (port == 0) {
|
578
603
|
cb(errc::common::service_not_available, {});
|
579
604
|
return;
|
580
605
|
}
|
581
606
|
auto new_session =
|
582
|
-
self->create_session(session->type(), session->credentials(), hostname, port);
|
607
|
+
self->create_session(session->type(), session->credentials(), hostname, port, node_uuid);
|
583
608
|
if (new_session->is_connected()) {
|
584
609
|
{
|
585
610
|
const std::scoped_lock inner_lock(self->sessions_mutex_);
|
@@ -679,15 +704,15 @@ private:
|
|
679
704
|
}
|
680
705
|
// stop this session and create a new one w/ new hostname + port
|
681
706
|
session->stop();
|
682
|
-
auto [hostname, port] = preferred_node.empty()
|
683
|
-
|
684
|
-
|
707
|
+
auto [hostname, port, node_uuid] = preferred_node.empty()
|
708
|
+
? self->next_node(session->type())
|
709
|
+
: self->lookup_node(session->type(), preferred_node);
|
685
710
|
if (port == 0) {
|
686
711
|
cmd->invoke_handler(errc::common::service_not_available, {});
|
687
712
|
return;
|
688
713
|
}
|
689
714
|
auto new_session =
|
690
|
-
self->create_session(session->type(), session->credentials(), hostname, port);
|
715
|
+
self->create_session(session->type(), session->credentials(), hostname, port, node_uuid);
|
691
716
|
cmd->set_command_session(new_session);
|
692
717
|
if (new_session->is_connected()) {
|
693
718
|
std::scoped_lock inner_lock(self->sessions_mutex_);
|
@@ -707,13 +732,15 @@ private:
|
|
707
732
|
auto create_session(service_type type,
|
708
733
|
const couchbase::core::cluster_credentials& credentials,
|
709
734
|
const std::string& hostname,
|
710
|
-
std::uint16_t port
|
735
|
+
std::uint16_t port,
|
736
|
+
const std::string& node_uuid) -> std::shared_ptr<http_session>
|
711
737
|
{
|
712
738
|
std::shared_ptr<http_session> session;
|
713
739
|
if (options_.enable_tls) {
|
714
740
|
session = std::make_shared<http_session>(
|
715
741
|
type,
|
716
742
|
client_id_,
|
743
|
+
node_uuid,
|
717
744
|
ctx_,
|
718
745
|
tls_,
|
719
746
|
credentials,
|
@@ -724,6 +751,7 @@ private:
|
|
724
751
|
session = std::make_shared<http_session>(
|
725
752
|
type,
|
726
753
|
client_id_,
|
754
|
+
node_uuid,
|
727
755
|
ctx_,
|
728
756
|
credentials,
|
729
757
|
hostname,
|
@@ -763,6 +791,7 @@ private:
|
|
763
791
|
request,
|
764
792
|
tracer_,
|
765
793
|
meter_,
|
794
|
+
app_telemetry_meter_,
|
766
795
|
options_.default_timeout_for(request.type),
|
767
796
|
dispatch_timeout_);
|
768
797
|
cmd->start([self = shared_from_this(), cmd, handler = std::forward<Handler>(handler)](
|
@@ -852,7 +881,7 @@ private:
|
|
852
881
|
}
|
853
882
|
#endif
|
854
883
|
|
855
|
-
auto next_node(service_type type) -> std::
|
884
|
+
auto next_node(service_type type) -> std::tuple<std::string, std::uint16_t, std::string>
|
856
885
|
{
|
857
886
|
std::scoped_lock lock(config_mutex_);
|
858
887
|
auto candidates = config_.nodes.size();
|
@@ -863,10 +892,18 @@ private:
|
|
863
892
|
next_index_ = (next_index_ + 1) % config_.nodes.size();
|
864
893
|
std::uint16_t port = node.port_or(options_.network, type, options_.enable_tls, 0);
|
865
894
|
if (port != 0) {
|
866
|
-
return {
|
895
|
+
return {
|
896
|
+
node.hostname_for(options_.network),
|
897
|
+
port,
|
898
|
+
node.node_uuid,
|
899
|
+
};
|
867
900
|
}
|
868
901
|
}
|
869
|
-
return {
|
902
|
+
return {
|
903
|
+
"",
|
904
|
+
static_cast<std::uint16_t>(0U),
|
905
|
+
"",
|
906
|
+
};
|
870
907
|
}
|
871
908
|
|
872
909
|
auto split_host_port(const std::string& address) -> std::pair<std::string, std::uint16_t>
|
@@ -880,24 +917,30 @@ private:
|
|
880
917
|
return { hostname, port };
|
881
918
|
}
|
882
919
|
|
883
|
-
auto lookup_node(service_type type,
|
884
|
-
|
920
|
+
auto lookup_node(service_type type, const std::string& preferred_node)
|
921
|
+
-> std::tuple<std::string, std::uint16_t, std::string>
|
885
922
|
{
|
886
923
|
std::scoped_lock lock(config_mutex_);
|
887
924
|
auto [hostname, port] = split_host_port(preferred_node);
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
925
|
+
for (const auto& node : config_.nodes) {
|
926
|
+
if (node.hostname_for(options_.network) == hostname &&
|
927
|
+
node.port_or(options_.network, type, options_.enable_tls, 0) == port) {
|
928
|
+
return {
|
929
|
+
hostname,
|
930
|
+
port,
|
931
|
+
node.node_uuid,
|
932
|
+
};
|
933
|
+
}
|
895
934
|
}
|
896
|
-
return {
|
935
|
+
return {
|
936
|
+
"",
|
937
|
+
static_cast<std::uint16_t>(0U),
|
938
|
+
"",
|
939
|
+
};
|
897
940
|
}
|
898
941
|
|
899
|
-
auto pick_random_node(service_type type,
|
900
|
-
|
942
|
+
auto pick_random_node(service_type type, const std::string& undesired_node)
|
943
|
+
-> std::tuple<std::string, std::uint16_t, std::string>
|
901
944
|
{
|
902
945
|
std::vector<topology::configuration::node> candidate_nodes{};
|
903
946
|
{
|
@@ -913,7 +956,11 @@ private:
|
|
913
956
|
|
914
957
|
if (candidate_nodes.empty()) {
|
915
958
|
// Could not find any other nodes
|
916
|
-
return {
|
959
|
+
return {
|
960
|
+
"",
|
961
|
+
static_cast<std::uint16_t>(0U),
|
962
|
+
"",
|
963
|
+
};
|
917
964
|
}
|
918
965
|
|
919
966
|
std::vector<topology::configuration::node> selected{};
|
@@ -922,8 +969,12 @@ private:
|
|
922
969
|
std::back_inserter(selected),
|
923
970
|
1,
|
924
971
|
std::mt19937{ std::random_device{}() });
|
925
|
-
|
926
|
-
|
972
|
+
const auto& first_selected = selected.at(0);
|
973
|
+
return {
|
974
|
+
first_selected.hostname_for(options_.network),
|
975
|
+
first_selected.port_or(options_.network, type, options_.enable_tls, 0),
|
976
|
+
first_selected.node_uuid,
|
977
|
+
};
|
927
978
|
}
|
928
979
|
|
929
980
|
std::string client_id_;
|
@@ -931,6 +982,7 @@ private:
|
|
931
982
|
asio::ssl::context& tls_;
|
932
983
|
std::shared_ptr<tracing::tracer_wrapper> tracer_{ nullptr };
|
933
984
|
std::shared_ptr<metrics::meter_wrapper> meter_{ nullptr };
|
985
|
+
std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter_{ nullptr };
|
934
986
|
cluster_options options_{};
|
935
987
|
|
936
988
|
topology::configuration config_{};
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
#pragma once
|
19
19
|
|
20
|
+
#include "core/app_telemetry_meter.hxx"
|
20
21
|
#include "core/document_id_fmt.hxx"
|
21
22
|
#include "core/error_context/key_value_error_map_info.hxx"
|
22
23
|
#include "core/metrics/meter_wrapper.hxx"
|
@@ -146,7 +147,12 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
|
|
146
147
|
span_ = nullptr;
|
147
148
|
}
|
148
149
|
if (handler) {
|
150
|
+
const auto& node_uuid = session_ ? session_->node_uuid() : "";
|
151
|
+
auto telemetry_recorder =
|
152
|
+
manager_->app_telemetry_meter()->value_recorder(node_uuid, manager_->name());
|
153
|
+
telemetry_recorder->update_counter(app_telemetry_counter::kv_r_total);
|
149
154
|
if (ec == errc::common::unambiguous_timeout || ec == errc::common::ambiguous_timeout) {
|
155
|
+
telemetry_recorder->update_counter(app_telemetry_counter::kv_r_timedout);
|
150
156
|
auto time_left = deadline.expiry() - std::chrono::steady_clock::now();
|
151
157
|
CB_LOG_TRACE(R"([{}] timeout operation id="{}", {}, key="{}", partition={}, time_left={})",
|
152
158
|
session_ ? session_->log_prefix() : manager_->log_prefix(),
|
@@ -155,6 +161,8 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
|
|
155
161
|
request.id,
|
156
162
|
request.partition,
|
157
163
|
time_left);
|
164
|
+
} else if (ec == errc::common::request_canceled) {
|
165
|
+
telemetry_recorder->update_counter(app_telemetry_counter::kv_r_canceled);
|
158
166
|
}
|
159
167
|
handler(ec, std::move(msg));
|
160
168
|
}
|
@@ -267,6 +275,35 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
|
|
267
275
|
retry_reason reason,
|
268
276
|
io::mcbp_message&& msg,
|
269
277
|
std::optional<key_value_error_map_info> /* error_info */) mutable {
|
278
|
+
{
|
279
|
+
auto latency = std::chrono::duration_cast<std::chrono::milliseconds>(
|
280
|
+
std::chrono::steady_clock::now() - start);
|
281
|
+
auto category = app_telemetry_latency::kv_retrieval;
|
282
|
+
switch (encoded_request_type::body_type::opcode) {
|
283
|
+
case protocol::client_opcode::upsert:
|
284
|
+
case protocol::client_opcode::insert:
|
285
|
+
case protocol::client_opcode::replace:
|
286
|
+
case protocol::client_opcode::remove:
|
287
|
+
case protocol::client_opcode::increment:
|
288
|
+
case protocol::client_opcode::decrement:
|
289
|
+
case protocol::client_opcode::append:
|
290
|
+
case protocol::client_opcode::prepend:
|
291
|
+
category = app_telemetry_latency::kv_mutation_nondurable;
|
292
|
+
if constexpr (io::mcbp_traits::supports_durability_v<Request>) {
|
293
|
+
if (self->request.durability_level != durability_level::none) {
|
294
|
+
category = app_telemetry_latency::kv_mutation_durable;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
break;
|
298
|
+
default:
|
299
|
+
break;
|
300
|
+
}
|
301
|
+
|
302
|
+
auto telemetry_recorder = self->manager_->app_telemetry_meter()->value_recorder(
|
303
|
+
self->session_->node_uuid(), self->manager_->name());
|
304
|
+
telemetry_recorder->record_latency(category, latency);
|
305
|
+
}
|
306
|
+
|
270
307
|
metrics::metric_attributes attrs{
|
271
308
|
service_type::key_value,
|
272
309
|
self->request.observability_identifier,
|
@@ -279,16 +316,18 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
|
|
279
316
|
|
280
317
|
self->retry_backoff.cancel();
|
281
318
|
if (ec == asio::error::operation_aborted) {
|
282
|
-
if (self->span_->uses_tags())
|
319
|
+
if (self->span_->uses_tags()) {
|
283
320
|
self->span_->add_tag(tracing::attributes::orphan, "aborted");
|
321
|
+
}
|
284
322
|
return self->invoke_handler(make_error_code(self->request.retries.idempotent()
|
285
323
|
? errc::common::unambiguous_timeout
|
286
324
|
: errc::common::ambiguous_timeout));
|
287
325
|
}
|
288
326
|
if (ec == errc::common::request_canceled) {
|
289
327
|
if (!self->request.retries.idempotent() && !allows_non_idempotent_retry(reason)) {
|
290
|
-
if (self->span_->uses_tags())
|
328
|
+
if (self->span_->uses_tags()) {
|
291
329
|
self->span_->add_tag(tracing::attributes::orphan, "canceled");
|
330
|
+
}
|
292
331
|
return self->invoke_handler(ec);
|
293
332
|
}
|
294
333
|
return io::retry_orchestrator::maybe_retry(self->manager_, self, reason, ec);
|
@@ -414,10 +414,11 @@ class mcbp_session_impl
|
|
414
414
|
const protocol::client_response<protocol::sasl_list_mechs_response_body> resp(
|
415
415
|
std::move(msg));
|
416
416
|
if (resp.status() != key_value_status_code::success) {
|
417
|
-
auto error_msg =
|
418
|
-
|
419
|
-
|
420
|
-
|
417
|
+
auto error_msg = fmt::format(
|
418
|
+
"unexpected message status during bootstrap: {} (opaque={}, context={})",
|
419
|
+
resp.error_message(),
|
420
|
+
resp.opaque(),
|
421
|
+
resp.error_info() ? resp.error_info()->context() : "");
|
421
422
|
last_bootstrap_error_ = { errc::common::authentication_failure,
|
422
423
|
std::move(error_msg),
|
423
424
|
session_->bootstrap_hostname(),
|
@@ -443,8 +444,11 @@ class mcbp_session_impl
|
|
443
444
|
req.body().sasl_data(sasl_payload);
|
444
445
|
session_->write_and_flush(req.data());
|
445
446
|
} else {
|
446
|
-
auto error_msg =
|
447
|
-
"unable to authenticate: (sasl_code={}, opaque={})",
|
447
|
+
auto error_msg =
|
448
|
+
fmt::format("unable to authenticate: (sasl_code={}, opaque={}, context={})",
|
449
|
+
sasl_code,
|
450
|
+
resp.opaque(),
|
451
|
+
resp.error_info() ? resp.error_info()->context() : "");
|
448
452
|
last_bootstrap_error_ = { errc::common::authentication_failure,
|
449
453
|
std::move(error_msg),
|
450
454
|
session_->bootstrap_hostname(),
|
@@ -453,11 +457,12 @@ class mcbp_session_impl
|
|
453
457
|
return complete(errc::common::authentication_failure);
|
454
458
|
}
|
455
459
|
} else {
|
456
|
-
auto error_msg =
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
460
|
+
auto error_msg = fmt::format(
|
461
|
+
"{} unexpected message status during bootstrap: {} (opaque={}, context={})",
|
462
|
+
session_->log_prefix_,
|
463
|
+
resp.error_message(),
|
464
|
+
resp.opaque(),
|
465
|
+
resp.error_info() ? resp.error_info()->context() : "");
|
461
466
|
last_bootstrap_error_ = { errc::common::authentication_failure,
|
462
467
|
std::move(error_msg),
|
463
468
|
session_->bootstrap_hostname(),
|
@@ -473,10 +478,11 @@ class mcbp_session_impl
|
|
473
478
|
return auth_success();
|
474
479
|
}
|
475
480
|
auto error_msg =
|
476
|
-
fmt::format("unable to authenticate (opcode={}, status={}, opaque={})",
|
481
|
+
fmt::format("unable to authenticate (opcode={}, status={}, opaque={}, context={})",
|
477
482
|
opcode,
|
478
483
|
resp.status(),
|
479
|
-
resp.opaque()
|
484
|
+
resp.opaque(),
|
485
|
+
resp.error_info() ? resp.error_info()->context() : "");
|
480
486
|
last_bootstrap_error_ = { errc::common::authentication_failure,
|
481
487
|
std::move(error_msg),
|
482
488
|
session_->bootstrap_hostname(),
|
@@ -858,19 +864,21 @@ class mcbp_session_impl
|
|
858
864
|
public:
|
859
865
|
mcbp_session_impl() = delete;
|
860
866
|
mcbp_session_impl(std::string_view client_id,
|
867
|
+
std::string_view node_uuid,
|
861
868
|
asio::io_context& ctx,
|
862
869
|
couchbase::core::origin origin,
|
863
870
|
std::shared_ptr<impl::bootstrap_state_listener> state_listener,
|
864
871
|
std::optional<std::string> bucket_name = {},
|
865
872
|
std::vector<protocol::hello_feature> known_features = {})
|
866
873
|
: client_id_(client_id)
|
874
|
+
, node_uuid_(node_uuid)
|
867
875
|
, ctx_(ctx)
|
868
876
|
, resolver_(ctx_)
|
869
877
|
, stream_(std::make_unique<plain_stream_impl>(ctx_))
|
870
878
|
, bootstrap_deadline_(ctx_)
|
871
879
|
, connection_deadline_(ctx_)
|
872
880
|
, retry_backoff_(ctx_)
|
873
|
-
,
|
881
|
+
, ping_timeout_(ctx_)
|
874
882
|
, origin_{ std::move(origin) }
|
875
883
|
, bucket_name_{ std::move(bucket_name) }
|
876
884
|
, supported_features_{ std::move(known_features) }
|
@@ -883,6 +891,7 @@ public:
|
|
883
891
|
}
|
884
892
|
|
885
893
|
mcbp_session_impl(std::string_view client_id,
|
894
|
+
std::string_view node_uuid,
|
886
895
|
asio::io_context& ctx,
|
887
896
|
asio::ssl::context& tls,
|
888
897
|
couchbase::core::origin origin,
|
@@ -890,13 +899,14 @@ public:
|
|
890
899
|
std::optional<std::string> bucket_name = {},
|
891
900
|
std::vector<protocol::hello_feature> known_features = {})
|
892
901
|
: client_id_(client_id)
|
902
|
+
, node_uuid_(node_uuid)
|
893
903
|
, ctx_(ctx)
|
894
904
|
, resolver_(ctx_)
|
895
905
|
, stream_(std::make_unique<tls_stream_impl>(ctx_, tls))
|
896
906
|
, bootstrap_deadline_(ctx_)
|
897
907
|
, connection_deadline_(ctx_)
|
898
908
|
, retry_backoff_(ctx_)
|
899
|
-
,
|
909
|
+
, ping_timeout_(ctx_)
|
900
910
|
, origin_(std::move(origin))
|
901
911
|
, bucket_name_(std::move(bucket_name))
|
902
912
|
, supported_features_(std::move(known_features))
|
@@ -998,8 +1008,8 @@ public:
|
|
998
1008
|
error,
|
999
1009
|
});
|
1000
1010
|
});
|
1001
|
-
|
1002
|
-
|
1011
|
+
ping_timeout_.expires_after(timeout.value_or(origin_.options().key_value_timeout));
|
1012
|
+
ping_timeout_.async_wait(
|
1003
1013
|
[self = this->shared_from_this(), opaque = req.opaque()](std::error_code ec) {
|
1004
1014
|
if (ec == asio::error::operation_aborted) {
|
1005
1015
|
return;
|
@@ -1154,6 +1164,11 @@ public:
|
|
1154
1164
|
return id_;
|
1155
1165
|
}
|
1156
1166
|
|
1167
|
+
[[nodiscard]] auto node_uuid() const -> const std::string&
|
1168
|
+
{
|
1169
|
+
return node_uuid_;
|
1170
|
+
}
|
1171
|
+
|
1157
1172
|
[[nodiscard]] auto is_stopped() const -> bool
|
1158
1173
|
{
|
1159
1174
|
return stopped_;
|
@@ -1194,7 +1209,7 @@ public:
|
|
1194
1209
|
bootstrap_deadline_.cancel();
|
1195
1210
|
connection_deadline_.cancel();
|
1196
1211
|
retry_backoff_.cancel();
|
1197
|
-
|
1212
|
+
ping_timeout_.cancel();
|
1198
1213
|
resolver_.cancel();
|
1199
1214
|
stream_->close([](std::error_code) {
|
1200
1215
|
});
|
@@ -1711,6 +1726,13 @@ private:
|
|
1711
1726
|
if (ec) {
|
1712
1727
|
return stop(retry_reason::node_not_available);
|
1713
1728
|
}
|
1729
|
+
if (node_uuid_.empty() && config_.has_value()) {
|
1730
|
+
for (const auto& node : config_.value().nodes) {
|
1731
|
+
if (node.this_node) {
|
1732
|
+
node_uuid_ = node.node_uuid;
|
1733
|
+
}
|
1734
|
+
}
|
1735
|
+
}
|
1714
1736
|
state_ = diag::endpoint_state::connected;
|
1715
1737
|
const std::scoped_lock lock(pending_buffer_mutex_);
|
1716
1738
|
bootstrapped_ = true;
|
@@ -2020,6 +2042,7 @@ private:
|
|
2020
2042
|
}
|
2021
2043
|
|
2022
2044
|
const std::string client_id_;
|
2045
|
+
std::string node_uuid_;
|
2023
2046
|
const std::string id_{ uuid::to_string(uuid::random()) };
|
2024
2047
|
asio::io_context& ctx_;
|
2025
2048
|
asio::ip::tcp::resolver resolver_;
|
@@ -2027,7 +2050,7 @@ private:
|
|
2027
2050
|
asio::steady_timer bootstrap_deadline_;
|
2028
2051
|
asio::steady_timer connection_deadline_;
|
2029
2052
|
asio::steady_timer retry_backoff_;
|
2030
|
-
asio::steady_timer
|
2053
|
+
asio::steady_timer ping_timeout_;
|
2031
2054
|
couchbase::core::origin origin_;
|
2032
2055
|
std::optional<std::string> bucket_name_;
|
2033
2056
|
mcbp_parser parser_;
|
@@ -2092,12 +2115,14 @@ private:
|
|
2092
2115
|
};
|
2093
2116
|
|
2094
2117
|
mcbp_session::mcbp_session(const std::string& client_id,
|
2118
|
+
const std::string& node_uuid,
|
2095
2119
|
asio::io_context& ctx,
|
2096
2120
|
core::origin origin,
|
2097
2121
|
std::shared_ptr<impl::bootstrap_state_listener> state_listener,
|
2098
2122
|
std::optional<std::string> bucket_name,
|
2099
2123
|
std::vector<protocol::hello_feature> known_features)
|
2100
2124
|
: impl_{ std::make_shared<mcbp_session_impl>(client_id,
|
2125
|
+
node_uuid,
|
2101
2126
|
ctx,
|
2102
2127
|
std::move(origin),
|
2103
2128
|
std::move(state_listener),
|
@@ -2107,6 +2132,7 @@ mcbp_session::mcbp_session(const std::string& client_id,
|
|
2107
2132
|
}
|
2108
2133
|
|
2109
2134
|
mcbp_session::mcbp_session(const std::string& client_id,
|
2135
|
+
const std::string& node_uuid,
|
2110
2136
|
asio::io_context& ctx,
|
2111
2137
|
asio::ssl::context& tls,
|
2112
2138
|
core::origin origin,
|
@@ -2114,6 +2140,7 @@ mcbp_session::mcbp_session(const std::string& client_id,
|
|
2114
2140
|
std::optional<std::string> bucket_name,
|
2115
2141
|
std::vector<protocol::hello_feature> known_features)
|
2116
2142
|
: impl_{ std::make_shared<mcbp_session_impl>(client_id,
|
2143
|
+
node_uuid,
|
2117
2144
|
ctx,
|
2118
2145
|
tls,
|
2119
2146
|
std::move(origin),
|
@@ -2177,6 +2204,12 @@ mcbp_session::id() const -> const std::string&
|
|
2177
2204
|
return impl_->id();
|
2178
2205
|
}
|
2179
2206
|
|
2207
|
+
auto
|
2208
|
+
mcbp_session::node_uuid() const -> const std::string&
|
2209
|
+
{
|
2210
|
+
return impl_->node_uuid();
|
2211
|
+
}
|
2212
|
+
|
2180
2213
|
auto
|
2181
2214
|
mcbp_session::bootstrap_address() const -> const std::string&
|
2182
2215
|
{
|
@@ -90,6 +90,7 @@ public:
|
|
90
90
|
auto operator=(mcbp_session&& other) -> mcbp_session& = default;
|
91
91
|
|
92
92
|
mcbp_session(const std::string& client_id,
|
93
|
+
const std::string& node_uuid,
|
93
94
|
asio::io_context& ctx,
|
94
95
|
couchbase::core::origin origin,
|
95
96
|
std::shared_ptr<impl::bootstrap_state_listener> state_listener,
|
@@ -97,6 +98,7 @@ public:
|
|
97
98
|
std::vector<protocol::hello_feature> known_features = {});
|
98
99
|
|
99
100
|
mcbp_session(const std::string& client_id,
|
101
|
+
const std::string& node_uuid,
|
100
102
|
asio::io_context& ctx,
|
101
103
|
asio::ssl::context& tls,
|
102
104
|
couchbase::core::origin origin,
|
@@ -115,6 +117,7 @@ public:
|
|
115
117
|
[[nodiscard]] auto supports_feature(protocol::hello_feature feature) -> bool;
|
116
118
|
[[nodiscard]] auto supported_features() const -> std::vector<protocol::hello_feature>;
|
117
119
|
[[nodiscard]] auto id() const -> const std::string&;
|
120
|
+
[[nodiscard]] auto node_uuid() const -> const std::string&;
|
118
121
|
[[nodiscard]] auto remote_address() const -> std::string;
|
119
122
|
[[nodiscard]] auto local_address() const -> std::string;
|
120
123
|
[[nodiscard]] auto bootstrap_address() const -> const std::string&;
|