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
@@ -166,9 +166,8 @@ public:
|
|
166
166
|
{
|
167
167
|
}
|
168
168
|
|
169
|
-
auto get_and_maybe_insert(std::string scope_name,
|
170
|
-
|
171
|
-
std::uint32_t id) -> std::shared_ptr<collection_id_cache_entry>
|
169
|
+
auto get_and_maybe_insert(std::string scope_name, std::string collection_name, std::uint32_t id)
|
170
|
+
-> std::shared_ptr<collection_id_cache_entry>
|
172
171
|
{
|
173
172
|
const std::scoped_lock lock(cache_mutex_);
|
174
173
|
auto key = build_key(scope_name, collection_name);
|
@@ -298,8 +297,8 @@ public:
|
|
298
297
|
return req;
|
299
298
|
}
|
300
299
|
|
301
|
-
auto direct_re_queue(std::shared_ptr<mcbp::queue_request> request,
|
302
|
-
|
300
|
+
auto direct_re_queue(std::shared_ptr<mcbp::queue_request> request, bool is_retry)
|
301
|
+
-> std::error_code
|
303
302
|
{
|
304
303
|
return dispatcher_.direct_re_queue(std::move(request), is_retry);
|
305
304
|
}
|
@@ -455,6 +454,9 @@ collection_id_cache_entry_impl::refresh_collection_id(
|
|
455
454
|
self->manager_.lock()->direct_re_queue(r, false);
|
456
455
|
});
|
457
456
|
});
|
457
|
+
#if defined(__clang__) && defined(__clang_analyzer__)
|
458
|
+
[[clang::suppress]]
|
459
|
+
#endif
|
458
460
|
// TODO(CXXCBC-549)
|
459
461
|
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
|
460
462
|
if (op) {
|
@@ -155,6 +155,9 @@ public:
|
|
155
155
|
if (!callback_) {
|
156
156
|
return;
|
157
157
|
}
|
158
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
159
|
+
dispatch_deadline_.cancel();
|
160
|
+
#endif
|
158
161
|
session_ = std::move(session);
|
159
162
|
|
160
163
|
auto start_op = [self = shared_from_this()]() {
|
@@ -344,6 +347,9 @@ public:
|
|
344
347
|
if (!callback_) {
|
345
348
|
return;
|
346
349
|
}
|
350
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
351
|
+
dispatch_deadline_.cancel();
|
352
|
+
#endif
|
347
353
|
session_ = std::move(session);
|
348
354
|
|
349
355
|
session_->write_and_subscribe(
|
@@ -61,6 +61,7 @@ map_bucket_settings(const couchbase::core::management::cluster::bucket_settings&
|
|
61
61
|
bucket_settings.flush_enabled = bucket.flush_enabled;
|
62
62
|
bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
|
63
63
|
bucket_settings.history_retention_duration = bucket.history_retention_duration;
|
64
|
+
bucket_settings.num_vbuckets = bucket.num_vbuckets;
|
64
65
|
switch (bucket.conflict_resolution_type) {
|
65
66
|
case core::management::cluster::bucket_conflict_resolution::unknown:
|
66
67
|
bucket_settings.conflict_resolution_type =
|
@@ -169,6 +170,7 @@ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucke
|
|
169
170
|
bucket.history_retention_collection_default;
|
170
171
|
bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
|
171
172
|
bucket_settings.history_retention_duration = bucket.history_retention_duration;
|
173
|
+
bucket_settings.num_vbuckets = bucket.num_vbuckets;
|
172
174
|
switch (bucket.conflict_resolution_type) {
|
173
175
|
case management::cluster::bucket_conflict_resolution::unknown:
|
174
176
|
bucket_settings.conflict_resolution_type =
|
@@ -140,6 +140,7 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
|
|
140
140
|
user_options.enable_mutation_tokens = opts.behavior.enable_mutation_tokens;
|
141
141
|
user_options.enable_unordered_execution = opts.behavior.enable_unordered_execution;
|
142
142
|
user_options.user_agent_extra = opts.behavior.user_agent_extra;
|
143
|
+
user_options.preserve_bootstrap_nodes_order = opts.behavior.preserve_bootstrap_nodes_order;
|
143
144
|
|
144
145
|
user_options.server_group = opts.network.server_group;
|
145
146
|
user_options.enable_tcp_keep_alive = opts.network.enable_tcp_keep_alive;
|
@@ -192,6 +193,15 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
|
|
192
193
|
user_options.tracing_options.eventing_threshold = opts.tracing.eventing_threshold;
|
193
194
|
}
|
194
195
|
user_options.transactions = opts.transactions;
|
196
|
+
|
197
|
+
user_options.enable_app_telemetry = opts.application_telemetry.enabled;
|
198
|
+
if (opts.application_telemetry.enabled) {
|
199
|
+
user_options.app_telemetry_endpoint = opts.application_telemetry.endpoint;
|
200
|
+
user_options.app_telemetry_ping_interval = opts.application_telemetry.ping_interval;
|
201
|
+
user_options.app_telemetry_ping_timeout = opts.application_telemetry.ping_timeout;
|
202
|
+
user_options.app_telemetry_backoff_interval = opts.application_telemetry.backoff_interval;
|
203
|
+
}
|
204
|
+
|
195
205
|
// connection string might override some user options
|
196
206
|
return { auth, core::utils::parse_connection_string(connection_string, user_options) };
|
197
207
|
}
|
@@ -523,6 +523,7 @@ public:
|
|
523
523
|
options.cas,
|
524
524
|
options.access_deleted,
|
525
525
|
options.create_as_deleted,
|
526
|
+
false,
|
526
527
|
options.expiry,
|
527
528
|
options.store_semantics,
|
528
529
|
specs,
|
@@ -558,6 +559,7 @@ public:
|
|
558
559
|
options.cas,
|
559
560
|
options.access_deleted,
|
560
561
|
options.create_as_deleted,
|
562
|
+
false,
|
561
563
|
options.expiry,
|
562
564
|
options.store_semantics,
|
563
565
|
specs,
|
@@ -35,6 +35,7 @@
|
|
35
35
|
#include "core/error_context/transaction_op_error_context.hxx"
|
36
36
|
#include "core/impl/internal_error_context.hxx"
|
37
37
|
#include "core/transactions/exceptions.hxx"
|
38
|
+
#include "core/transactions/exceptions_fmt.hxx"
|
38
39
|
#include "core/transactions/internal/exceptions_internal.hxx"
|
39
40
|
|
40
41
|
#include <couchbase/error.hxx>
|
@@ -184,15 +185,30 @@ make_error(const couchbase::core::transaction_error_context& ctx) -> error
|
|
184
185
|
}
|
185
186
|
|
186
187
|
auto
|
187
|
-
make_error(const
|
188
|
+
make_error(const core::transactions::op_exception& exc) -> error
|
188
189
|
{
|
189
|
-
|
190
|
-
|
190
|
+
std::optional<error> cause;
|
191
|
+
if (std::holds_alternative<key_value_error_context>(exc.ctx().cause())) {
|
192
|
+
cause = make_error(std::get<key_value_error_context>(exc.ctx().cause()));
|
191
193
|
}
|
192
|
-
if (std::holds_alternative<query_error_context>(ctx.cause())) {
|
193
|
-
|
194
|
+
if (std::holds_alternative<query_error_context>(exc.ctx().cause())) {
|
195
|
+
cause = make_error(std::get<query_error_context>(exc.ctx().cause()));
|
194
196
|
}
|
195
|
-
|
197
|
+
|
198
|
+
if (cause.has_value()) {
|
199
|
+
return error{
|
200
|
+
transaction_op_errc_from_external_exception(exc.cause()),
|
201
|
+
exc.what(),
|
202
|
+
{},
|
203
|
+
cause.value(),
|
204
|
+
};
|
205
|
+
}
|
206
|
+
|
207
|
+
return error{
|
208
|
+
transaction_op_errc_from_external_exception(exc.cause()),
|
209
|
+
exc.what(),
|
210
|
+
{},
|
211
|
+
};
|
196
212
|
}
|
197
213
|
|
198
214
|
auto
|
@@ -57,7 +57,7 @@ auto
|
|
57
57
|
make_error(const couchbase::core::transaction_error_context& core_ctx) -> error;
|
58
58
|
|
59
59
|
auto
|
60
|
-
make_error(const couchbase::core::
|
60
|
+
make_error(const couchbase::core::transactions::op_exception& exc) -> error;
|
61
61
|
|
62
62
|
auto
|
63
63
|
make_error(const couchbase::core::transactions::transaction_operation_failed& core_tof) -> error;
|
@@ -47,8 +47,59 @@ convert_log_level(couchbase::logger::log_level level) -> core::logger::level
|
|
47
47
|
}
|
48
48
|
return core::logger::level::off;
|
49
49
|
}
|
50
|
+
|
51
|
+
auto
|
52
|
+
convert_log_level(core::logger::level level) -> couchbase::logger::log_level
|
53
|
+
{
|
54
|
+
switch (level) {
|
55
|
+
case core::logger::level::trace:
|
56
|
+
return log_level::trace;
|
57
|
+
case core::logger::level::debug:
|
58
|
+
return log_level::debug;
|
59
|
+
case core::logger::level::info:
|
60
|
+
return log_level::info;
|
61
|
+
case core::logger::level::warn:
|
62
|
+
return log_level::warn;
|
63
|
+
case core::logger::level::err:
|
64
|
+
return log_level::error;
|
65
|
+
case core::logger::level::critical:
|
66
|
+
return log_level::critical;
|
67
|
+
case core::logger::level::off:
|
68
|
+
default:
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
return log_level::off;
|
72
|
+
}
|
73
|
+
|
74
|
+
auto
|
75
|
+
convert_log_location(const core::logger::log_location& location) -> couchbase::logger::log_location
|
76
|
+
{
|
77
|
+
return couchbase::logger::log_location{ location.file, location.function, location.line };
|
78
|
+
}
|
50
79
|
} // namespace
|
51
80
|
|
81
|
+
void
|
82
|
+
register_log_callback(const log_callback& callback)
|
83
|
+
{
|
84
|
+
if (callback == nullptr) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
|
88
|
+
auto core_callback = [callback](const std::string_view msg,
|
89
|
+
const core::logger::level level,
|
90
|
+
const core::logger::log_location& location) {
|
91
|
+
callback(msg, convert_log_level(level), convert_log_location(location));
|
92
|
+
};
|
93
|
+
|
94
|
+
couchbase::core::logger::register_log_callback(std::move(core_callback));
|
95
|
+
}
|
96
|
+
|
97
|
+
void
|
98
|
+
unregister_log_callback()
|
99
|
+
{
|
100
|
+
couchbase::core::logger::unregister_log_callback();
|
101
|
+
}
|
102
|
+
|
52
103
|
void
|
53
104
|
set_level(log_level level)
|
54
105
|
{
|
@@ -29,7 +29,7 @@ effective_nodes(const document_id& id,
|
|
29
29
|
const read_preference& preference,
|
30
30
|
const std::string& preferred_server_group) -> std::vector<readable_node>
|
31
31
|
{
|
32
|
-
if (preference
|
32
|
+
if (preference == read_preference::selected_server_group && preferred_server_group.empty()) {
|
33
33
|
CB_LOG_WARNING("Preferred server group is required for zone-aware replica reads");
|
34
34
|
return {};
|
35
35
|
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2021-Present Couchbase, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx>
|
18
|
+
|
19
|
+
#include <couchbase/collection.hxx>
|
20
|
+
|
21
|
+
namespace couchbase::transactions
|
22
|
+
{
|
23
|
+
transaction_get_multi_replicas_from_preferred_server_group_spec::
|
24
|
+
transaction_get_multi_replicas_from_preferred_server_group_spec(const collection& collection,
|
25
|
+
std::string id)
|
26
|
+
: bucket_{ collection.bucket_name() }
|
27
|
+
, scope_{ collection.scope_name() }
|
28
|
+
, collection_{ collection.name() }
|
29
|
+
, id_{ std::move(id) }
|
30
|
+
{
|
31
|
+
}
|
32
|
+
} // namespace couchbase::transactions
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2021-Present Couchbase, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include <couchbase/transactions/transaction_get_multi_spec.hxx>
|
18
|
+
|
19
|
+
#include <couchbase/collection.hxx>
|
20
|
+
|
21
|
+
namespace couchbase::transactions
|
22
|
+
{
|
23
|
+
transaction_get_multi_spec::transaction_get_multi_spec(const collection& collection, std::string id)
|
24
|
+
: bucket_{ collection.bucket_name() }
|
25
|
+
, scope_{ collection.scope_name() }
|
26
|
+
, collection_{ collection.name() }
|
27
|
+
, id_{ std::move(id) }
|
28
|
+
{
|
29
|
+
}
|
30
|
+
} // namespace couchbase::transactions
|
@@ -70,6 +70,8 @@ struct transaction_op_error_category : std::error_category {
|
|
70
70
|
return "transaction_already_aborted (1318)";
|
71
71
|
case errc::transaction_op::transaction_already_committed:
|
72
72
|
return "transaction_already_committed (1319)";
|
73
|
+
case errc::transaction_op::document_unretrievable:
|
74
|
+
return "document_unretrievable (1320)";
|
73
75
|
case errc::transaction_op::transaction_op_failed:
|
74
76
|
return "transaction_op_failed (1399)";
|
75
77
|
}
|
@@ -99,8 +99,8 @@ public:
|
|
99
99
|
{
|
100
100
|
io::mcbp_session new_session =
|
101
101
|
origin_.options().enable_tls
|
102
|
-
? io::mcbp_session(client_id_, ctx_, tls_, origin_, state_listener_)
|
103
|
-
: io::mcbp_session(client_id_, ctx_, origin_, state_listener_);
|
102
|
+
? io::mcbp_session(client_id_, {}, ctx_, tls_, origin_, state_listener_)
|
103
|
+
: io::mcbp_session(client_id_, {}, ctx_, origin_, state_listener_);
|
104
104
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
105
105
|
new_session.add_background_bootstrap_listener(shared_from_this());
|
106
106
|
#endif
|
@@ -395,8 +395,8 @@ private:
|
|
395
395
|
origin_.credentials(), hostname, port, origin_.options());
|
396
396
|
io::mcbp_session session =
|
397
397
|
origin_.options().enable_tls
|
398
|
-
? io::mcbp_session(client_id_, ctx_, tls_, origin, state_listener_)
|
399
|
-
: io::mcbp_session(client_id_, ctx_, origin, state_listener_);
|
398
|
+
? io::mcbp_session(client_id_, node.node_uuid, ctx_, tls_, origin, state_listener_)
|
399
|
+
: io::mcbp_session(client_id_, node.node_uuid, ctx_, origin, state_listener_);
|
400
400
|
CB_LOG_DEBUG(R"({} rev={}, add cluster session="{}", address="{}:{}")",
|
401
401
|
log_prefix_,
|
402
402
|
config.rev_str(),
|
@@ -500,8 +500,8 @@ private:
|
|
500
500
|
origin_.credentials(), hostname, port, origin_.options());
|
501
501
|
io::mcbp_session session =
|
502
502
|
origin_.options().enable_tls
|
503
|
-
? io::mcbp_session(client_id_, ctx_, tls_, origin, state_listener_)
|
504
|
-
: io::mcbp_session(client_id_, ctx_, origin, state_listener_);
|
503
|
+
? io::mcbp_session(client_id_, node.node_uuid, ctx_, tls_, origin, state_listener_)
|
504
|
+
: io::mcbp_session(client_id_, node.node_uuid, ctx_, origin, state_listener_);
|
505
505
|
CB_LOG_DEBUG(R"({} rev={}, restart cluster session="{}", address="{}:{}")",
|
506
506
|
log_prefix_,
|
507
507
|
config_->rev_str(),
|
@@ -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/impl/bootstrap_error.hxx"
|
23
24
|
#include "core/metrics/meter_wrapper.hxx"
|
24
25
|
#include "core/service_type_fmt.hxx"
|
@@ -52,6 +53,7 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
52
53
|
std::shared_ptr<tracing::tracer_wrapper> tracer_;
|
53
54
|
std::shared_ptr<couchbase::tracing::request_span> span_{ nullptr };
|
54
55
|
std::shared_ptr<metrics::meter_wrapper> meter_{};
|
56
|
+
std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter_{ nullptr };
|
55
57
|
std::shared_ptr<io::http_session> session_{};
|
56
58
|
http_command_handler handler_{};
|
57
59
|
std::chrono::milliseconds timeout_{};
|
@@ -65,12 +67,14 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
65
67
|
Request req,
|
66
68
|
std::shared_ptr<tracing::tracer_wrapper> tracer,
|
67
69
|
std::shared_ptr<metrics::meter_wrapper> meter,
|
70
|
+
std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter,
|
68
71
|
std::chrono::milliseconds default_timeout,
|
69
72
|
std::chrono::milliseconds dispatch_timeout)
|
70
73
|
: deadline(ctx)
|
71
74
|
, request(req)
|
72
75
|
, tracer_(std::move(tracer))
|
73
76
|
, meter_(std::move(meter))
|
77
|
+
, app_telemetry_meter_(std::move(app_telemetry_meter))
|
74
78
|
, timeout_(request.timeout.value_or(default_timeout))
|
75
79
|
, client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
|
76
80
|
, dispatch_timeout_(dispatch_timeout)
|
@@ -85,11 +89,13 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
85
89
|
Request req,
|
86
90
|
std::shared_ptr<tracing::tracer_wrapper> tracer,
|
87
91
|
std::shared_ptr<metrics::meter_wrapper> meter,
|
92
|
+
std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter,
|
88
93
|
std::chrono::milliseconds default_timeout)
|
89
94
|
: deadline(ctx)
|
90
95
|
, request(req)
|
91
96
|
, tracer_(std::move(tracer))
|
92
97
|
, meter_(std::move(meter))
|
98
|
+
, app_telemetry_meter_(std::move(app_telemetry_meter))
|
93
99
|
, timeout_(request.timeout.value_or(default_timeout))
|
94
100
|
, client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
|
95
101
|
{
|
@@ -128,12 +134,9 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
128
134
|
if (ec == asio::error::operation_aborted) {
|
129
135
|
return;
|
130
136
|
}
|
131
|
-
CB_LOG_DEBUG(
|
132
|
-
|
133
|
-
|
134
|
-
self->encoded.method,
|
135
|
-
self->encoded.path,
|
136
|
-
self->client_context_id_);
|
137
|
+
CB_LOG_DEBUG(R"(HTTP request timed out before dispatch: {}, client_context_id="{}")",
|
138
|
+
self->request.type,
|
139
|
+
self->client_context_id_);
|
137
140
|
self->cancel(errc::common::unambiguous_timeout);
|
138
141
|
});
|
139
142
|
#endif
|
@@ -142,10 +145,8 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
142
145
|
if (ec == asio::error::operation_aborted) {
|
143
146
|
return;
|
144
147
|
}
|
145
|
-
CB_LOG_DEBUG(R"(HTTP request timed out: {},
|
146
|
-
self->
|
147
|
-
self->encoded.method,
|
148
|
-
self->encoded.path,
|
148
|
+
CB_LOG_DEBUG(R"(HTTP request timed out: {}, client_context_id="{}")",
|
149
|
+
self->request.type,
|
149
150
|
self->client_context_id_);
|
150
151
|
if constexpr (io::http_traits::supports_readonly_v<Request>) {
|
151
152
|
if (self->request.readonly) {
|
@@ -176,6 +177,22 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
176
177
|
span_ = nullptr;
|
177
178
|
}
|
178
179
|
if (auto handler = std::move(handler_); handler) {
|
180
|
+
const auto& node_uuid = session_ ? session_->node_uuid() : "";
|
181
|
+
auto telemetry_recorder = app_telemetry_meter_->value_recorder(node_uuid, {});
|
182
|
+
telemetry_recorder->update_counter(total_counter_for_service_type(request.type));
|
183
|
+
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
184
|
+
std::error_code ec{};
|
185
|
+
if (std::holds_alternative<std::error_code>(error)) {
|
186
|
+
ec = std::get<std::error_code>(error);
|
187
|
+
} else if (std::holds_alternative<impl::bootstrap_error>(error)) {
|
188
|
+
ec = std::get<impl::bootstrap_error>(error).ec;
|
189
|
+
}
|
190
|
+
#endif
|
191
|
+
if (ec == errc::common::ambiguous_timeout || ec == errc::common::unambiguous_timeout) {
|
192
|
+
telemetry_recorder->update_counter(timedout_counter_for_service_type(request.type));
|
193
|
+
} else if (ec == errc::common::request_canceled) {
|
194
|
+
telemetry_recorder->update_counter(canceled_counter_for_service_type(request.type));
|
195
|
+
}
|
179
196
|
#ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
|
180
197
|
handler(error, std::move(msg));
|
181
198
|
}
|
@@ -195,8 +212,9 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
|
|
195
212
|
if (!handler_) {
|
196
213
|
return;
|
197
214
|
}
|
198
|
-
if (span_->uses_tags())
|
215
|
+
if (span_->uses_tags()) {
|
199
216
|
span_->add_tag(tracing::attributes::local_id, session_->id());
|
217
|
+
}
|
200
218
|
send();
|
201
219
|
}
|
202
220
|
|
@@ -244,6 +262,12 @@ private:
|
|
244
262
|
if (ec == asio::error::operation_aborted) {
|
245
263
|
return self->invoke_handler(errc::common::ambiguous_timeout, std::move(msg));
|
246
264
|
}
|
265
|
+
|
266
|
+
auto latency = std::chrono::duration_cast<std::chrono::milliseconds>(
|
267
|
+
std::chrono::steady_clock::now() - start);
|
268
|
+
self->app_telemetry_meter_->value_recorder(self->session_->node_uuid(), {})
|
269
|
+
->record_latency(latency_for_service_type(self->request.type), latency);
|
270
|
+
|
247
271
|
if (self->meter_) {
|
248
272
|
metrics::metric_attributes attrs{
|
249
273
|
self->request.type,
|
@@ -100,6 +100,7 @@ http_session_info::log_prefix() const -> const std::string&
|
|
100
100
|
|
101
101
|
http_session::http_session(couchbase::core::service_type type,
|
102
102
|
std::string client_id,
|
103
|
+
std::string node_uuid,
|
103
104
|
asio::io_context& ctx,
|
104
105
|
couchbase::core::cluster_credentials credentials,
|
105
106
|
std::string hostname,
|
@@ -107,6 +108,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
107
108
|
couchbase::core::http_context http_ctx)
|
108
109
|
: type_(type)
|
109
110
|
, client_id_(std::move(client_id))
|
111
|
+
, node_uuid_(std::move(node_uuid))
|
110
112
|
, id_(uuid::to_string(uuid::random()))
|
111
113
|
, ctx_(ctx)
|
112
114
|
, resolver_(ctx_)
|
@@ -125,6 +127,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
125
127
|
|
126
128
|
http_session::http_session(couchbase::core::service_type type,
|
127
129
|
std::string client_id,
|
130
|
+
std::string node_uuid,
|
128
131
|
asio::io_context& ctx,
|
129
132
|
asio::ssl::context& tls,
|
130
133
|
couchbase::core::cluster_credentials credentials,
|
@@ -133,6 +136,7 @@ http_session::http_session(couchbase::core::service_type type,
|
|
133
136
|
couchbase::core::http_context http_ctx)
|
134
137
|
: type_(type)
|
135
138
|
, client_id_(std::move(client_id))
|
139
|
+
, node_uuid_(std::move(node_uuid))
|
136
140
|
, id_(uuid::to_string(uuid::random()))
|
137
141
|
, ctx_(ctx)
|
138
142
|
, resolver_(ctx_)
|
@@ -207,6 +211,12 @@ http_session::id() const -> const std::string&
|
|
207
211
|
return id_;
|
208
212
|
}
|
209
213
|
|
214
|
+
auto
|
215
|
+
http_session::node_uuid() const -> const std::string&
|
216
|
+
{
|
217
|
+
return node_uuid_;
|
218
|
+
}
|
219
|
+
|
210
220
|
auto
|
211
221
|
http_session::credentials() const -> const cluster_credentials&
|
212
222
|
{
|
@@ -71,6 +71,7 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
71
71
|
public:
|
72
72
|
http_session(service_type type,
|
73
73
|
std::string client_id,
|
74
|
+
std::string node_uuid,
|
74
75
|
asio::io_context& ctx,
|
75
76
|
cluster_credentials credentials,
|
76
77
|
std::string hostname,
|
@@ -79,6 +80,7 @@ public:
|
|
79
80
|
|
80
81
|
http_session(service_type type,
|
81
82
|
std::string client_id,
|
83
|
+
std::string node_uuid,
|
82
84
|
asio::io_context& ctx,
|
83
85
|
asio::ssl::context& tls,
|
84
86
|
cluster_credentials credentials,
|
@@ -95,6 +97,7 @@ public:
|
|
95
97
|
[[nodiscard]] auto diag_info() -> diag::endpoint_diag_info;
|
96
98
|
[[nodiscard]] auto log_prefix() -> std::string;
|
97
99
|
[[nodiscard]] auto id() const -> const std::string&;
|
100
|
+
[[nodiscard]] auto node_uuid() const -> const std::string&;
|
98
101
|
[[nodiscard]] auto credentials() const -> const cluster_credentials&;
|
99
102
|
[[nodiscard]] auto is_connected() const -> bool;
|
100
103
|
[[nodiscard]] auto type() const -> service_type;
|
@@ -196,6 +199,7 @@ private:
|
|
196
199
|
|
197
200
|
service_type type_{};
|
198
201
|
std::string client_id_;
|
202
|
+
std::string node_uuid_;
|
199
203
|
std::string id_;
|
200
204
|
asio::io_context& ctx_;
|
201
205
|
asio::ip::tcp::resolver resolver_;
|