couchbase 3.5.7 → 3.6.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/cache/extconf_include.rb +3 -3
- data/ext/cache/mozilla-ca-bundle.crt +3 -165
- data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
- data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/CMakeLists.txt +14 -10
- data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.cc +7 -4
- data/ext/couchbase/CMakeLists.txt +12 -1
- data/ext/couchbase/cmake/Profiler.cmake +15 -0
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +2 -2
- data/ext/couchbase/cmake/couchbase_cxx_client.pc.in +1 -1
- data/ext/couchbase/core/app_telemetry_address.cxx +55 -0
- data/ext/couchbase/core/app_telemetry_address.hxx +39 -0
- data/ext/couchbase/core/app_telemetry_meter.cxx +753 -0
- data/ext/couchbase/core/app_telemetry_meter.hxx +198 -0
- data/ext/couchbase/core/app_telemetry_reporter.cxx +895 -0
- data/ext/couchbase/core/app_telemetry_reporter.hxx +59 -0
- data/ext/couchbase/core/bucket.cxx +77 -35
- data/ext/couchbase/core/bucket.hxx +17 -10
- data/ext/couchbase/core/cluster.cxx +54 -16
- data/ext/couchbase/core/cluster_credentials.cxx +27 -0
- data/ext/couchbase/core/cluster_credentials.hxx +36 -0
- data/ext/couchbase/core/cluster_options.hxx +12 -0
- data/ext/couchbase/core/collections_component.cxx +7 -5
- data/ext/couchbase/core/http_component.cxx +6 -0
- data/ext/couchbase/core/impl/binary_collection.cxx +4 -0
- data/ext/couchbase/core/impl/bucket_manager.cxx +2 -0
- data/ext/couchbase/core/impl/cluster.cxx +9 -0
- data/ext/couchbase/core/impl/collection.cxx +2 -0
- data/ext/couchbase/core/impl/error.cxx +1 -0
- data/ext/couchbase/core/impl/logger.cxx +51 -0
- data/ext/couchbase/core/impl/replica_utils.cxx +1 -1
- data/ext/couchbase/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
- data/ext/couchbase/core/impl/transaction_get_multi_spec.cxx +30 -0
- data/ext/couchbase/core/impl/transaction_op_error_category.cxx +2 -0
- data/ext/couchbase/core/io/config_tracker.cxx +6 -6
- data/ext/couchbase/core/io/http_command.hxx +35 -11
- data/ext/couchbase/core/io/http_session.cxx +10 -0
- data/ext/couchbase/core/io/http_session.hxx +4 -0
- data/ext/couchbase/core/io/http_session_manager.hxx +83 -34
- data/ext/couchbase/core/io/mcbp_command.hxx +41 -2
- data/ext/couchbase/core/io/mcbp_session.cxx +52 -19
- data/ext/couchbase/core/io/mcbp_session.hxx +3 -0
- data/ext/couchbase/core/logger/logger.cxx +46 -0
- data/ext/couchbase/core/logger/logger.hxx +41 -1
- data/ext/couchbase/core/management/bucket_settings.hxx +1 -0
- data/ext/couchbase/core/management/bucket_settings_json.hxx +4 -0
- data/ext/couchbase/core/meta/features.hxx +32 -0
- data/ext/couchbase/core/operations/document_analytics.cxx +9 -9
- data/ext/couchbase/core/operations/document_append.cxx +1 -0
- data/ext/couchbase/core/operations/document_append.hxx +1 -0
- data/ext/couchbase/core/operations/document_get_all_replicas.hxx +10 -2
- data/ext/couchbase/core/operations/document_lookup_in.cxx +4 -0
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +14 -2
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +4 -0
- data/ext/couchbase/core/operations/document_mutate_in.cxx +4 -0
- data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -0
- data/ext/couchbase/core/operations/document_prepend.cxx +1 -0
- data/ext/couchbase/core/operations/document_prepend.hxx +1 -0
- data/ext/couchbase/core/operations/document_query.cxx +12 -10
- data/ext/couchbase/core/operations/http_noop.cxx +1 -0
- data/ext/couchbase/core/operations/management/bucket_create.cxx +3 -0
- data/ext/couchbase/core/operations/management/bucket_update.cxx +3 -0
- data/ext/couchbase/core/origin.cxx +0 -5
- data/ext/couchbase/core/origin.hxx +2 -11
- data/ext/couchbase/core/platform/random.cc +6 -3
- data/ext/couchbase/core/platform/random.h +2 -2
- data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +9 -0
- data/ext/couchbase/core/timeout_defaults.hxx +4 -0
- data/ext/couchbase/core/topology/configuration.cxx +10 -13
- data/ext/couchbase/core/topology/configuration.hxx +14 -15
- data/ext/couchbase/core/topology/configuration_json.hxx +6 -0
- data/ext/couchbase/core/transactions/async_attempt_context.hxx +22 -2
- data/ext/couchbase/core/transactions/attempt_context.hxx +25 -7
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +688 -238
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +91 -12
- data/ext/couchbase/core/transactions/exceptions.cxx +5 -0
- data/ext/couchbase/core/transactions/exceptions.hxx +20 -0
- data/ext/couchbase/core/transactions/exceptions_fmt.hxx +3 -0
- data/ext/couchbase/core/transactions/forward_compat.cxx +71 -6
- data/ext/couchbase/core/transactions/forward_compat.hxx +45 -59
- data/ext/couchbase/core/transactions/get_multi_orchestrator.cxx +616 -0
- data/ext/couchbase/core/transactions/get_multi_orchestrator.hxx +61 -0
- data/ext/couchbase/core/transactions/internal/doc_record.cxx +8 -0
- data/ext/couchbase/core/transactions/internal/doc_record.hxx +16 -5
- data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +12 -0
- data/ext/couchbase/core/transactions/internal/transaction_context.hxx +13 -0
- data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +1 -0
- data/ext/couchbase/core/transactions/staged_mutation.cxx +277 -96
- data/ext/couchbase/core/transactions/staged_mutation.hxx +28 -76
- data/ext/couchbase/core/transactions/transaction_context.cxx +33 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_mode.hxx +28 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +71 -0
- data/ext/couchbase/core/transactions/transaction_get_multi_result.hxx +66 -0
- data/ext/couchbase/core/transactions/transaction_links.hxx +10 -0
- data/ext/couchbase/core/transactions/transactions.cxx +8 -3
- data/ext/couchbase/core/utils/connection_string.cxx +4 -0
- data/ext/couchbase/core/utils/url_codec.cxx +26 -0
- data/ext/couchbase/core/utils/url_codec.hxx +11 -0
- data/ext/couchbase/core/websocket_codec.cxx +647 -0
- data/ext/couchbase/core/websocket_codec.hxx +77 -0
- data/ext/couchbase/couchbase/analytics_options.hxx +70 -6
- data/ext/couchbase/couchbase/application_telemetry_options.hxx +124 -0
- data/ext/couchbase/couchbase/cluster_options.hxx +17 -0
- data/ext/couchbase/couchbase/error_codes.hxx +1 -0
- data/ext/couchbase/couchbase/logger.hxx +16 -0
- data/ext/couchbase/couchbase/management/bucket_settings.hxx +1 -0
- data/ext/couchbase/couchbase/query_options.hxx +70 -6
- data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +29 -5
- data/ext/couchbase/couchbase/transactions/attempt_context.hxx +24 -7
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +109 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_result.hxx +102 -0
- data/ext/couchbase/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
- data/ext/rcb_buckets.cxx +26 -0
- data/lib/active_support/cache/couchbase_store.rb +1 -1
- data/lib/couchbase/cluster.rb +1 -1
- data/lib/couchbase/collection.rb +1 -1
- data/lib/couchbase/collection_options.rb +2 -2
- data/lib/couchbase/management/analytics_index_manager.rb +4 -4
- data/lib/couchbase/management/bucket_manager.rb +8 -2
- data/lib/couchbase/protostellar/cluster.rb +2 -2
- data/lib/couchbase/protostellar/collection.rb +1 -1
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +1 -1
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +4 -4
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +6 -6
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +13 -13
- data/lib/couchbase/protostellar/request_generator/kv.rb +25 -25
- data/lib/couchbase/protostellar/request_generator/query.rb +4 -4
- data/lib/couchbase/protostellar/request_generator/search.rb +25 -25
- data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
- data/lib/couchbase/protostellar/retry/reason.rb +1 -1
- data/lib/couchbase/protostellar/timeouts.rb +1 -1
- data/lib/couchbase/scope.rb +1 -1
- data/lib/couchbase/transcoder_flags.rb +1 -1
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -1
- data/lib/couchbase/version.rb +1 -1
- metadata +47 -19
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/COPYING +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/SnappyConfig.cmake.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/config.h.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-internal.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.cc +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.h +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-public.h.in +0 -0
- /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.h +0 -0
@@ -24,11 +24,20 @@
|
|
24
24
|
#include "attempt_state.hxx"
|
25
25
|
#include "internal/atr_cleanup_entry.hxx"
|
26
26
|
#include "internal/exceptions_internal.hxx"
|
27
|
+
#include "transaction_get_multi_mode.hxx"
|
27
28
|
#include "transaction_get_result.hxx"
|
28
29
|
|
30
|
+
// TODO(SA): do not mix public and core APIs in the single class
|
31
|
+
#include <chrono>
|
29
32
|
#include <couchbase/codec/encoded_value.hxx>
|
30
33
|
#include <couchbase/transactions/async_attempt_context.hxx>
|
31
34
|
#include <couchbase/transactions/attempt_context.hxx>
|
35
|
+
#include <couchbase/transactions/transaction_get_multi_options.hxx>
|
36
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx>
|
37
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx>
|
38
|
+
#include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx>
|
39
|
+
#include <couchbase/transactions/transaction_get_multi_result.hxx>
|
40
|
+
#include <couchbase/transactions/transaction_get_multi_spec.hxx>
|
32
41
|
#include <couchbase/transactions/transaction_query_options.hxx>
|
33
42
|
|
34
43
|
#include <cstdint>
|
@@ -62,7 +71,7 @@ namespace transactions
|
|
62
71
|
* insert and delete documents, as well as commit or rollback the transaction.
|
63
72
|
*/
|
64
73
|
class transactions;
|
65
|
-
enum class forward_compat_stage;
|
74
|
+
enum class forward_compat_stage : std::uint8_t;
|
66
75
|
class staged_mutation_queue;
|
67
76
|
class staged_mutation;
|
68
77
|
struct attempt_context_testing_hooks;
|
@@ -96,15 +105,15 @@ private:
|
|
96
105
|
codec::encoded_value content,
|
97
106
|
core::transactions::async_attempt_context::Callback&& cb) override;
|
98
107
|
|
99
|
-
auto insert(const core::document_id& id,
|
100
|
-
|
108
|
+
auto insert(const core::document_id& id, codec::encoded_value content)
|
109
|
+
-> core::transactions::transaction_get_result override;
|
101
110
|
|
102
111
|
void replace(const transaction_get_result& document,
|
103
112
|
codec::encoded_value content,
|
104
113
|
core::transactions::async_attempt_context::Callback&& cb) override;
|
105
114
|
|
106
|
-
auto replace(const transaction_get_result& document,
|
107
|
-
|
115
|
+
auto replace(const transaction_get_result& document, codec::encoded_value content)
|
116
|
+
-> transaction_get_result override;
|
108
117
|
|
109
118
|
auto insert_raw(const collection& coll, const std::string& id, codec::encoded_value content)
|
110
119
|
-> std::pair<couchbase::error, couchbase::transactions::transaction_get_result> override;
|
@@ -159,12 +168,24 @@ private:
|
|
159
168
|
|
160
169
|
void handle_err_from_callback(const std::exception_ptr& e);
|
161
170
|
|
171
|
+
template<typename Cb, typename E, typename T>
|
172
|
+
void op_completed_with_callback(Cb&& cb, E e, std::optional<T> t)
|
173
|
+
{
|
174
|
+
try {
|
175
|
+
op_list_.decrement_in_flight();
|
176
|
+
std::forward<Cb>(cb)(std::make_exception_ptr(std::forward<E>(e)), t);
|
177
|
+
op_list_.decrement_ops();
|
178
|
+
} catch (...) {
|
179
|
+
handle_err_from_callback(std::current_exception());
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
162
183
|
template<typename Cb, typename T>
|
163
184
|
void op_completed_with_callback(Cb&& cb, std::optional<T> t)
|
164
185
|
{
|
165
186
|
try {
|
166
187
|
op_list_.decrement_in_flight();
|
167
|
-
cb({}, t);
|
188
|
+
std::forward<Cb>(cb)({}, t);
|
168
189
|
op_list_.decrement_ops();
|
169
190
|
} catch (...) {
|
170
191
|
handle_err_from_callback(std::current_exception());
|
@@ -176,7 +197,7 @@ private:
|
|
176
197
|
{
|
177
198
|
try {
|
178
199
|
op_list_.decrement_in_flight();
|
179
|
-
cb({});
|
200
|
+
std::forward<Cb>(cb)({});
|
180
201
|
op_list_.decrement_ops();
|
181
202
|
} catch (...) {
|
182
203
|
handle_err_from_callback(std::current_exception());
|
@@ -237,7 +258,7 @@ private:
|
|
237
258
|
void op_completed_with_error_no_cache(VoidCallback cb, std::exception_ptr err)
|
238
259
|
{
|
239
260
|
try {
|
240
|
-
cb(err);
|
261
|
+
cb(std::move(err));
|
241
262
|
} catch (...) {
|
242
263
|
// just eat it.
|
243
264
|
}
|
@@ -285,11 +306,12 @@ private:
|
|
285
306
|
}
|
286
307
|
}
|
287
308
|
|
288
|
-
[[nodiscard]] auto cluster_ref() const -> const core::cluster&;
|
289
|
-
|
290
309
|
explicit attempt_context_impl(const std::shared_ptr<transaction_context>& transaction_ctx);
|
291
310
|
|
292
311
|
public:
|
312
|
+
[[nodiscard]] auto cluster_ref() const -> const core::cluster&;
|
313
|
+
[[nodiscard]] auto expiry_time() const -> std::chrono::steady_clock::time_point;
|
314
|
+
|
293
315
|
static auto create(const std::shared_ptr<transaction_context>& transaction_ctx)
|
294
316
|
-> std::shared_ptr<attempt_context_impl>;
|
295
317
|
|
@@ -327,6 +349,56 @@ public:
|
|
327
349
|
const std::string& id,
|
328
350
|
couchbase::transactions::async_result_handler&& handler) override;
|
329
351
|
|
352
|
+
auto get_multi(const std::vector<core::document_id>& ids, transaction_get_multi_mode mode)
|
353
|
+
-> transaction_get_multi_result override;
|
354
|
+
void get_multi(const std::vector<core::document_id>& ids,
|
355
|
+
transaction_get_multi_mode mode,
|
356
|
+
std::function<void(std::exception_ptr,
|
357
|
+
std::optional<transaction_get_multi_result>)>&& cb) override;
|
358
|
+
auto get_multi(const std::vector<couchbase::transactions::transaction_get_multi_spec>& specs,
|
359
|
+
const couchbase::transactions::transaction_get_multi_options& options)
|
360
|
+
-> std::pair<error,
|
361
|
+
std::optional<couchbase::transactions::transaction_get_multi_result>> override;
|
362
|
+
void get_multi(
|
363
|
+
const std::vector<couchbase::transactions::transaction_get_multi_spec>& specs,
|
364
|
+
const couchbase::transactions::transaction_get_multi_options& options,
|
365
|
+
std::function<void(error,
|
366
|
+
std::optional<couchbase::transactions::transaction_get_multi_result>)>&& cb)
|
367
|
+
override;
|
368
|
+
|
369
|
+
auto get_multi_replicas_from_preferred_server_group(
|
370
|
+
const std::vector<core::document_id>& ids,
|
371
|
+
transaction_get_multi_replicas_from_preferred_server_group_mode mode)
|
372
|
+
-> transaction_get_multi_replicas_from_preferred_server_group_result override;
|
373
|
+
void get_multi_replicas_from_preferred_server_group(
|
374
|
+
const std::vector<core::document_id>& ids,
|
375
|
+
transaction_get_multi_replicas_from_preferred_server_group_mode mode,
|
376
|
+
std::function<
|
377
|
+
void(std::exception_ptr,
|
378
|
+
std::optional<transaction_get_multi_replicas_from_preferred_server_group_result>)>&& cb)
|
379
|
+
override;
|
380
|
+
auto get_multi_replicas_from_preferred_server_group(
|
381
|
+
const std::vector<
|
382
|
+
couchbase::transactions::transaction_get_multi_replicas_from_preferred_server_group_spec>&
|
383
|
+
specs,
|
384
|
+
const couchbase::transactions::
|
385
|
+
transaction_get_multi_replicas_from_preferred_server_group_options& options)
|
386
|
+
-> std::pair<
|
387
|
+
error,
|
388
|
+
std::optional<couchbase::transactions::
|
389
|
+
transaction_get_multi_replicas_from_preferred_server_group_result>> override;
|
390
|
+
void get_multi_replicas_from_preferred_server_group(
|
391
|
+
const std::vector<
|
392
|
+
couchbase::transactions::transaction_get_multi_replicas_from_preferred_server_group_spec>&
|
393
|
+
specs,
|
394
|
+
const couchbase::transactions::
|
395
|
+
transaction_get_multi_replicas_from_preferred_server_group_options& options,
|
396
|
+
std::function<void(
|
397
|
+
error,
|
398
|
+
std::optional<couchbase::transactions::
|
399
|
+
transaction_get_multi_replicas_from_preferred_server_group_result>)>&& cb)
|
400
|
+
override;
|
401
|
+
|
330
402
|
void remove(const transaction_get_result& document) override;
|
331
403
|
auto remove(const couchbase::transactions::transaction_get_result& doc)
|
332
404
|
-> couchbase::error override;
|
@@ -438,6 +510,7 @@ private:
|
|
438
510
|
void get_doc(const core::document_id& id,
|
439
511
|
bool allow_replica,
|
440
512
|
std::function<void(std::optional<error_class>,
|
513
|
+
std::optional<external_exception>,
|
441
514
|
std::optional<std::string>,
|
442
515
|
std::optional<transaction_get_result>)>&& cb);
|
443
516
|
|
@@ -455,9 +528,12 @@ private:
|
|
455
528
|
Handler&& cb);
|
456
529
|
|
457
530
|
template<typename Handler>
|
458
|
-
void create_staged_replace(const
|
531
|
+
void create_staged_replace(const document_id& id,
|
459
532
|
codec::encoded_value content,
|
533
|
+
std::uint32_t original_flags,
|
534
|
+
const couchbase::cas& cas,
|
460
535
|
const std::string& op_id,
|
536
|
+
const std::optional<document_metadata>& document_metadata,
|
461
537
|
Handler&& cb);
|
462
538
|
|
463
539
|
template<typename Handler, typename Delay>
|
@@ -472,7 +548,10 @@ private:
|
|
472
548
|
const std::string& message);
|
473
549
|
|
474
550
|
void ensure_open_bucket(const std::string& bucket_name,
|
475
|
-
std::function<void(std::error_code)>&& handler);
|
551
|
+
std::function<void(std::error_code)>&& handler) const;
|
552
|
+
|
553
|
+
void supports_replace_body_with_xattr(const std::string& bucket_name,
|
554
|
+
std::function<void(std::error_code, bool)>&& handler) const;
|
476
555
|
};
|
477
556
|
|
478
557
|
} // namespace transactions
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#include "internal/transaction_context.hxx"
|
18
18
|
|
19
19
|
#include "exceptions.hxx"
|
20
|
+
#include "exceptions_fmt.hxx"
|
20
21
|
|
21
22
|
namespace couchbase::core::transactions
|
22
23
|
{
|
@@ -156,6 +157,8 @@ transaction_op_errc_from_external_exception(external_exception e) -> errc::trans
|
|
156
157
|
return errc::transaction_op::transaction_already_aborted;
|
157
158
|
case external_exception::TRANSACTION_ALREADY_COMMITTED:
|
158
159
|
return errc::transaction_op::transaction_already_committed;
|
160
|
+
case external_exception::DOCUMENT_UNRETRIEVABLE_EXCEPTION:
|
161
|
+
return errc::transaction_op::document_unretrievable;
|
159
162
|
}
|
160
163
|
return errc::transaction_op::generic;
|
161
164
|
}
|
@@ -204,6 +207,8 @@ external_exception_from_transaction_op_errc(errc::transaction_op ec) -> external
|
|
204
207
|
return external_exception::TRANSACTION_ALREADY_ABORTED;
|
205
208
|
case errc::transaction_op::transaction_already_committed:
|
206
209
|
return external_exception::TRANSACTION_ALREADY_COMMITTED;
|
210
|
+
case errc::transaction_op::document_unretrievable:
|
211
|
+
return external_exception::DOCUMENT_UNRETRIEVABLE_EXCEPTION;
|
207
212
|
default:
|
208
213
|
return external_exception::UNKNOWN;
|
209
214
|
}
|
@@ -63,6 +63,7 @@ enum external_exception {
|
|
63
63
|
ROLLBACK_NOT_PERMITTED,
|
64
64
|
TRANSACTION_ALREADY_ABORTED,
|
65
65
|
TRANSACTION_ALREADY_COMMITTED,
|
66
|
+
DOCUMENT_UNRETRIEVABLE_EXCEPTION,
|
66
67
|
};
|
67
68
|
|
68
69
|
auto
|
@@ -151,6 +152,12 @@ public:
|
|
151
152
|
return { ec, transaction_op_errc_from_external_exception(cause_) };
|
152
153
|
}
|
153
154
|
};
|
155
|
+
|
156
|
+
/**
|
157
|
+
* op_exception represents errors raised from transactions operations that are _not_ wrapped in a
|
158
|
+
* transaction_operation_failed. They might be wrapped in a transaction_operation_failed eventually,
|
159
|
+
* or they might be raised directly from the lambda.
|
160
|
+
*/
|
154
161
|
class op_exception : public std::runtime_error
|
155
162
|
{
|
156
163
|
private:
|
@@ -166,6 +173,15 @@ public:
|
|
166
173
|
{
|
167
174
|
}
|
168
175
|
|
176
|
+
explicit op_exception(transaction_op_error_context ctx,
|
177
|
+
const std::string& what,
|
178
|
+
external_exception cause = COUCHBASE_EXCEPTION)
|
179
|
+
: std::runtime_error(what)
|
180
|
+
, cause_(cause)
|
181
|
+
, ctx_(std::move(ctx))
|
182
|
+
{
|
183
|
+
}
|
184
|
+
|
169
185
|
/**
|
170
186
|
* For converting from Public API error (for errors propagated from lambda)
|
171
187
|
*/
|
@@ -178,6 +194,10 @@ public:
|
|
178
194
|
|
179
195
|
[[nodiscard]] auto cause() const -> external_exception
|
180
196
|
{
|
197
|
+
// TODO(DC): This doesn't appear to be a 'cause' in the sense that we use it elsewhere, but more
|
198
|
+
// like the 'external_exception' equivalent of the error code inside the ctx. We should probably
|
199
|
+
// rename this or simplify this class. This is used to set the 'cause' field of
|
200
|
+
// transaction_operation_failed.
|
181
201
|
return cause_;
|
182
202
|
}
|
183
203
|
|
@@ -99,6 +99,9 @@ struct fmt::formatter<couchbase::core::transactions::external_exception> {
|
|
99
99
|
case couchbase::core::transactions::TRANSACTION_ALREADY_COMMITTED:
|
100
100
|
name = "TRANSACTION_ALREADY_COMMITTED";
|
101
101
|
break;
|
102
|
+
case couchbase::core::transactions::DOCUMENT_UNRETRIEVABLE_EXCEPTION:
|
103
|
+
name = "DOCUMENT_UNRETRIEVABLE_EXCEPTION";
|
104
|
+
break;
|
102
105
|
}
|
103
106
|
return format_to(ctx.out(), "{}", name);
|
104
107
|
}
|
@@ -127,19 +127,19 @@ auto
|
|
127
127
|
create_forward_compat_stage(const std::string& str) -> forward_compat_stage
|
128
128
|
{
|
129
129
|
if (str == "WW_R") {
|
130
|
-
return forward_compat_stage::
|
130
|
+
return forward_compat_stage::WRITE_WRITE_CONFLICT_READING_ATR;
|
131
131
|
}
|
132
132
|
if (str == "WW_RP") {
|
133
|
-
return forward_compat_stage::
|
133
|
+
return forward_compat_stage::WRITE_WRITE_CONFLICT_REPLACING;
|
134
134
|
}
|
135
135
|
if (str == "WW_RM") {
|
136
|
-
return forward_compat_stage::
|
136
|
+
return forward_compat_stage::WRITE_WRITE_CONFLICT_REMOVING;
|
137
137
|
}
|
138
138
|
if (str == "WW_I") {
|
139
|
-
return forward_compat_stage::
|
139
|
+
return forward_compat_stage::WRITE_WRITE_CONFLICT_INSERTING;
|
140
140
|
}
|
141
141
|
if (str == "WW_IG") {
|
142
|
-
return forward_compat_stage::
|
142
|
+
return forward_compat_stage::WRITE_WRITE_CONFLICT_INSERTING_GET;
|
143
143
|
}
|
144
144
|
if (str == "G") {
|
145
145
|
return forward_compat_stage::GETS;
|
@@ -150,7 +150,19 @@ create_forward_compat_stage(const std::string& str) -> forward_compat_stage
|
|
150
150
|
if (str == "CL_E") {
|
151
151
|
return forward_compat_stage::CLEANUP_ENTRY;
|
152
152
|
}
|
153
|
-
|
153
|
+
if (str == "CM_C") {
|
154
|
+
return forward_compat_stage::CAS_MISMATCH_DURING_COMMIT;
|
155
|
+
}
|
156
|
+
if (str == "CM_R") {
|
157
|
+
return forward_compat_stage::CAS_MISMATCH_DURING_ROLLBACK;
|
158
|
+
}
|
159
|
+
if (str == "CM_S") {
|
160
|
+
return forward_compat_stage::CAS_MISMATCH_DURING_STAGING;
|
161
|
+
}
|
162
|
+
if (str == "GM_G") {
|
163
|
+
return forward_compat_stage::GET_MULTI_GET;
|
164
|
+
}
|
165
|
+
throw std::runtime_error(fmt::format("Unknown forward compatibility stage: {}", str));
|
154
166
|
}
|
155
167
|
|
156
168
|
class forward_compat
|
@@ -228,4 +240,57 @@ check_forward_compat(forward_compat_stage stage, std::optional<tao::json::value>
|
|
228
240
|
return std::nullopt;
|
229
241
|
}
|
230
242
|
|
243
|
+
auto
|
244
|
+
to_string(forward_compat_stage value) -> std::string
|
245
|
+
{
|
246
|
+
switch (value) {
|
247
|
+
case forward_compat_stage::WRITE_WRITE_CONFLICT_READING_ATR:
|
248
|
+
return "WW_R";
|
249
|
+
case forward_compat_stage::WRITE_WRITE_CONFLICT_REPLACING:
|
250
|
+
return "WW_RP";
|
251
|
+
case forward_compat_stage::WRITE_WRITE_CONFLICT_REMOVING:
|
252
|
+
return "WW_RM";
|
253
|
+
case forward_compat_stage::WRITE_WRITE_CONFLICT_INSERTING:
|
254
|
+
return "WW_I";
|
255
|
+
case forward_compat_stage::WRITE_WRITE_CONFLICT_INSERTING_GET:
|
256
|
+
return "WW_IG";
|
257
|
+
case forward_compat_stage::GETS:
|
258
|
+
return "G";
|
259
|
+
case forward_compat_stage::GETS_READING_ATR:
|
260
|
+
return "G_A";
|
261
|
+
case forward_compat_stage::CLEANUP_ENTRY:
|
262
|
+
return "CL_E";
|
263
|
+
case forward_compat_stage::CAS_MISMATCH_DURING_COMMIT:
|
264
|
+
return "CM_C";
|
265
|
+
case forward_compat_stage::CAS_MISMATCH_DURING_ROLLBACK:
|
266
|
+
return "CM_R";
|
267
|
+
case forward_compat_stage::CAS_MISMATCH_DURING_STAGING:
|
268
|
+
return "CM_S";
|
269
|
+
case forward_compat_stage::GET_MULTI_GET:
|
270
|
+
return "GM_G";
|
271
|
+
};
|
272
|
+
throw std::runtime_error(
|
273
|
+
fmt::format("Unknown forward compatibility stage: {}", static_cast<std::uint8_t>(value)));
|
274
|
+
}
|
275
|
+
auto
|
276
|
+
create_forward_compat_behavior(const std::string& str) -> forward_compat_behavior
|
277
|
+
{
|
278
|
+
if (str == "r") {
|
279
|
+
return forward_compat_behavior::RETRY_TXN;
|
280
|
+
}
|
281
|
+
return forward_compat_behavior::FAIL_FAST_TXN;
|
282
|
+
}
|
283
|
+
auto
|
284
|
+
forward_compat_behavior_name(forward_compat_behavior b) -> const char*
|
285
|
+
{
|
286
|
+
switch (b) {
|
287
|
+
case forward_compat_behavior::CONTINUE:
|
288
|
+
return "CONTINUE";
|
289
|
+
case forward_compat_behavior::RETRY_TXN:
|
290
|
+
return "RETRY_TXN";
|
291
|
+
case forward_compat_behavior::FAIL_FAST_TXN:
|
292
|
+
return "FAIL_FAST_TRANSACTION";
|
293
|
+
}
|
294
|
+
return "unknown behavior";
|
295
|
+
}
|
231
296
|
} // namespace couchbase::core::transactions
|
@@ -16,91 +16,77 @@
|
|
16
16
|
#pragma once
|
17
17
|
|
18
18
|
#include "internal/exceptions_internal.hxx"
|
19
|
+
|
19
20
|
#include <cstdint>
|
20
|
-
#include <list>
|
21
21
|
#include <optional>
|
22
|
-
#include <stdexcept>
|
23
22
|
#include <string>
|
23
|
+
#include <vector>
|
24
24
|
|
25
25
|
namespace couchbase::core::transactions
|
26
26
|
{
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
WWC_INSERTING_GET,
|
27
|
+
enum class forward_compat_stage : std::uint8_t {
|
28
|
+
WRITE_WRITE_CONFLICT_READING_ATR,
|
29
|
+
WRITE_WRITE_CONFLICT_REPLACING,
|
30
|
+
WRITE_WRITE_CONFLICT_REMOVING,
|
31
|
+
WRITE_WRITE_CONFLICT_INSERTING,
|
32
|
+
WRITE_WRITE_CONFLICT_INSERTING_GET,
|
34
33
|
GETS,
|
35
34
|
GETS_READING_ATR,
|
36
|
-
CLEANUP_ENTRY
|
35
|
+
CLEANUP_ENTRY,
|
36
|
+
CAS_MISMATCH_DURING_COMMIT,
|
37
|
+
CAS_MISMATCH_DURING_ROLLBACK,
|
38
|
+
CAS_MISMATCH_DURING_STAGING,
|
39
|
+
GET_MULTI_GET,
|
37
40
|
};
|
38
41
|
|
39
|
-
|
40
|
-
to_string(forward_compat_stage value) ->
|
41
|
-
{
|
42
|
-
switch (value) {
|
43
|
-
case forward_compat_stage::WWC_READING_ATR:
|
44
|
-
return "WW_R";
|
45
|
-
case forward_compat_stage::WWC_REPLACING:
|
46
|
-
return "WW_RP";
|
47
|
-
case forward_compat_stage::WWC_REMOVING:
|
48
|
-
return "WW_RM";
|
49
|
-
case forward_compat_stage::WWC_INSERTING:
|
50
|
-
return "WW_I";
|
51
|
-
case forward_compat_stage::WWC_INSERTING_GET:
|
52
|
-
return "WW_IG";
|
53
|
-
case forward_compat_stage::GETS:
|
54
|
-
return "G";
|
55
|
-
case forward_compat_stage::GETS_READING_ATR:
|
56
|
-
return "G_A";
|
57
|
-
case forward_compat_stage::CLEANUP_ENTRY:
|
58
|
-
return "CL_E";
|
59
|
-
};
|
60
|
-
throw std::runtime_error("Unknown forward compatibility stage");
|
61
|
-
}
|
42
|
+
auto
|
43
|
+
to_string(forward_compat_stage value) -> std::string;
|
62
44
|
|
63
|
-
enum class forward_compat_behavior {
|
45
|
+
enum class forward_compat_behavior : std::uint8_t {
|
64
46
|
CONTINUE,
|
65
47
|
RETRY_TXN,
|
66
48
|
FAIL_FAST_TXN
|
67
49
|
};
|
68
50
|
|
69
|
-
|
70
|
-
create_forward_compat_behavior(const std::string& str) -> forward_compat_behavior
|
71
|
-
{
|
72
|
-
if (str == "r") {
|
73
|
-
return forward_compat_behavior::RETRY_TXN;
|
74
|
-
}
|
75
|
-
return forward_compat_behavior::FAIL_FAST_TXN;
|
76
|
-
}
|
51
|
+
auto
|
52
|
+
create_forward_compat_behavior(const std::string& str) -> forward_compat_behavior;
|
77
53
|
|
78
54
|
// used only for logging
|
79
|
-
|
80
|
-
forward_compat_behavior_name(forward_compat_behavior b) -> const char
|
81
|
-
{
|
82
|
-
switch (b) {
|
83
|
-
case forward_compat_behavior::CONTINUE:
|
84
|
-
return "CONTINUE";
|
85
|
-
case forward_compat_behavior::RETRY_TXN:
|
86
|
-
return "RETRY_TXN";
|
87
|
-
case forward_compat_behavior::FAIL_FAST_TXN:
|
88
|
-
return "FAIL_FAST_TRANSACTION";
|
89
|
-
}
|
90
|
-
return "unknown behavior";
|
91
|
-
}
|
55
|
+
auto
|
56
|
+
forward_compat_behavior_name(forward_compat_behavior b) -> const char*;
|
92
57
|
|
93
58
|
struct forward_compat_supported {
|
94
59
|
std::uint32_t protocol_major = 2;
|
95
60
|
std::uint32_t protocol_minor = 0;
|
96
61
|
std::list<std::string> extensions{
|
97
|
-
"
|
98
|
-
"
|
62
|
+
"BF3705", // BF-CBD-3705
|
63
|
+
"BF3787", // BF-CBD-3787
|
64
|
+
"BF3791", // BF-CBD-3791
|
65
|
+
"BF3838", // BF-CBD-3838
|
66
|
+
"BM", // ExtBinaryMetadata
|
67
|
+
"BS", // ExtBinarySupport
|
68
|
+
"CM", // ExtCustomMetadataCollection
|
69
|
+
"CO", // ExtAllKVCombinations
|
70
|
+
"IX", // ExtInsertExisting
|
71
|
+
"MO", // ExtMemoryOptUnstaging
|
72
|
+
"PU", // ExtParallelUnstaging
|
73
|
+
"QC", // ExtQueryContext
|
74
|
+
"QU", // ExtQuery
|
75
|
+
"RC", // ExtRemoveCompleted
|
76
|
+
"RP", // ExtReplicaFromPreferredGroup
|
77
|
+
"RX", // ExtReplaceBodyWithXattr
|
78
|
+
"SD", // ExtStoreDurability
|
79
|
+
"SI", // ExtSDKIntegration
|
80
|
+
"TI", // ExtTransactionId
|
81
|
+
"TS", // ExtThreadSafety
|
82
|
+
"UA", // ExtUnknownATRStates
|
83
|
+
"GM", // ExtGetMulti
|
99
84
|
};
|
100
85
|
};
|
101
86
|
|
102
87
|
class transaction_operation_failed;
|
103
88
|
|
104
|
-
|
105
|
-
check_forward_compat(forward_compat_stage stage, std::optional<tao::json::value> json)
|
89
|
+
auto
|
90
|
+
check_forward_compat(forward_compat_stage stage, std::optional<tao::json::value> json)
|
91
|
+
-> std::optional<transaction_operation_failed>;
|
106
92
|
} // namespace couchbase::core::transactions
|