couchbase 3.4.1 → 3.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/couchbase/CMakeLists.txt +59 -7
- data/ext/couchbase/cmake/Documentation.cmake +0 -1
- data/ext/couchbase/cmake/OpenSSL.cmake +98 -3
- data/ext/couchbase/cmake/Testing.cmake +12 -4
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +4 -0
- data/ext/couchbase/cmake/build_config.hxx.in +3 -0
- data/ext/couchbase/core/bucket.cxx +3 -2
- data/ext/couchbase/core/bucket.hxx +9 -0
- data/ext/couchbase/core/cluster.hxx +17 -0
- data/ext/couchbase/core/cluster_options.cxx +2 -2
- data/ext/couchbase/core/cluster_options.hxx +4 -7
- data/ext/couchbase/core/{config_profile.cxx → cluster_options_fwd.hxx} +7 -6
- data/ext/couchbase/core/config_profile.hxx +2 -65
- data/ext/couchbase/core/config_profiles.cxx +79 -0
- data/ext/couchbase/core/config_profiles.hxx +56 -0
- data/ext/couchbase/core/error_context/search.hxx +1 -1
- data/ext/couchbase/core/impl/analytics.cxx +237 -0
- data/ext/couchbase/core/impl/boolean_field_query.cxx +40 -0
- data/ext/couchbase/core/impl/boolean_query.cxx +62 -0
- data/ext/couchbase/core/impl/cluster.cxx +2 -1
- data/ext/couchbase/core/impl/conjunction_query.cxx +51 -0
- data/ext/couchbase/core/impl/date_range.cxx +89 -0
- data/ext/couchbase/core/impl/date_range_facet.cxx +54 -0
- data/ext/couchbase/core/impl/date_range_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/date_range_query.cxx +125 -0
- data/ext/couchbase/core/impl/disjunction_query.cxx +51 -0
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +5 -3
- data/ext/couchbase/core/impl/encoded_search_facet.hxx +29 -0
- data/ext/couchbase/core/impl/encoded_search_query.hxx +29 -0
- data/ext/couchbase/core/impl/encoded_search_sort.hxx +29 -0
- data/ext/couchbase/core/impl/geo_bounding_box_query.cxx +46 -0
- data/ext/couchbase/core/impl/geo_distance_query.cxx +43 -0
- data/ext/couchbase/core/impl/geo_polygon_query.cxx +46 -0
- data/ext/couchbase/core/impl/internal_date_range_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_date_range_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_numeric_range_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/internal_search_error_context.cxx +141 -0
- data/ext/couchbase/core/impl/internal_search_error_context.hxx +61 -0
- data/ext/couchbase/core/impl/internal_search_meta_data.cxx +60 -0
- data/ext/couchbase/core/impl/internal_search_meta_data.hxx +41 -0
- data/ext/couchbase/core/impl/internal_search_result.cxx +84 -0
- data/ext/couchbase/core/impl/internal_search_result.hxx +43 -0
- data/ext/couchbase/core/impl/internal_search_row.cxx +82 -0
- data/ext/couchbase/core/impl/internal_search_row.hxx +56 -0
- data/ext/couchbase/core/impl/internal_search_row_location.hxx +32 -0
- data/ext/couchbase/core/impl/internal_search_row_locations.cxx +137 -0
- data/ext/couchbase/core/impl/internal_search_row_locations.hxx +45 -0
- data/ext/couchbase/core/impl/internal_term_facet_result.cxx +80 -0
- data/ext/couchbase/core/impl/internal_term_facet_result.hxx +48 -0
- data/ext/couchbase/core/impl/match_all_query.cxx +35 -0
- data/ext/couchbase/core/impl/match_none_query.cxx +35 -0
- data/ext/couchbase/core/impl/match_phrase_query.cxx +43 -0
- data/ext/couchbase/core/impl/match_query.cxx +59 -0
- data/ext/couchbase/core/impl/numeric_range.cxx +49 -0
- data/ext/couchbase/core/impl/numeric_range_facet.cxx +54 -0
- data/ext/couchbase/core/impl/numeric_range_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/numeric_range_query.cxx +56 -0
- data/ext/couchbase/core/impl/phrase_query.cxx +42 -0
- data/ext/couchbase/core/impl/prefix_query.cxx +40 -0
- data/ext/couchbase/core/impl/query.cxx +5 -5
- data/ext/couchbase/core/impl/query_string_query.cxx +37 -0
- data/ext/couchbase/core/impl/regexp_query.cxx +40 -0
- data/ext/couchbase/core/impl/search.cxx +191 -0
- data/ext/couchbase/core/impl/search_error_context.cxx +147 -0
- data/ext/couchbase/core/impl/search_meta_data.cxx +46 -0
- data/ext/couchbase/core/impl/search_result.cxx +66 -0
- data/ext/couchbase/core/impl/search_row.cxx +74 -0
- data/ext/couchbase/core/impl/search_row_location.cxx +64 -0
- data/ext/couchbase/core/impl/search_row_locations.cxx +66 -0
- data/ext/couchbase/core/impl/search_sort_field.cxx +104 -0
- data/ext/couchbase/core/impl/search_sort_id.cxx +43 -0
- data/ext/couchbase/core/impl/search_sort_score.cxx +43 -0
- data/ext/couchbase/core/impl/term_facet.cxx +36 -0
- data/ext/couchbase/core/impl/term_facet_result.cxx +64 -0
- data/ext/couchbase/core/impl/term_query.cxx +56 -0
- data/ext/couchbase/core/impl/term_range_query.cxx +57 -0
- data/ext/couchbase/core/impl/wildcard_query.cxx +40 -0
- data/ext/couchbase/core/io/dns_client.cxx +225 -0
- data/ext/couchbase/core/io/dns_client.hxx +19 -188
- data/ext/couchbase/core/io/http_context.hxx +1 -1
- data/ext/couchbase/core/io/http_session.hxx +10 -0
- data/ext/couchbase/core/io/http_session_manager.hxx +5 -3
- data/ext/couchbase/core/io/mcbp_session.cxx +28 -1
- data/ext/couchbase/core/io/retry_orchestrator.hxx +3 -2
- data/ext/couchbase/core/json_string.hxx +5 -0
- data/ext/couchbase/core/meta/version.cxx +18 -4
- data/ext/couchbase/core/mozilla_ca_bundle.hxx +39 -0
- data/ext/couchbase/core/operations/document_analytics.cxx +1 -0
- data/ext/couchbase/core/operations/document_analytics.hxx +1 -0
- data/ext/couchbase/core/operations/document_append.hxx +1 -1
- data/ext/couchbase/core/operations/document_decrement.hxx +1 -1
- data/ext/couchbase/core/operations/document_exists.hxx +1 -1
- data/ext/couchbase/core/operations/document_get.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_and_lock.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_and_touch.hxx +1 -1
- data/ext/couchbase/core/operations/document_get_projected.hxx +1 -1
- data/ext/couchbase/core/operations/document_increment.hxx +1 -1
- data/ext/couchbase/core/operations/document_insert.hxx +1 -1
- data/ext/couchbase/core/operations/document_lookup_in.hxx +1 -1
- data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -1
- data/ext/couchbase/core/operations/document_prepend.hxx +1 -1
- data/ext/couchbase/core/operations/document_query.cxx +2 -0
- data/ext/couchbase/core/operations/document_query.hxx +6 -0
- data/ext/couchbase/core/operations/document_remove.hxx +1 -1
- data/ext/couchbase/core/operations/document_replace.hxx +1 -1
- data/ext/couchbase/core/operations/document_search.cxx +4 -1
- data/ext/couchbase/core/operations/document_search.hxx +2 -1
- data/ext/couchbase/core/operations/document_touch.hxx +1 -1
- data/ext/couchbase/core/operations/document_unlock.hxx +1 -1
- data/ext/couchbase/core/operations/document_upsert.hxx +1 -1
- data/ext/couchbase/core/operations/document_view.hxx +1 -0
- data/ext/couchbase/core/protocol/client_request.hxx +11 -2
- data/ext/couchbase/core/public_fwd.hxx +21 -0
- data/ext/couchbase/core/tls_verify_mode.hxx +26 -0
- data/ext/couchbase/core/topology/configuration.cxx +15 -2
- data/ext/couchbase/core/topology/configuration.hxx +5 -1
- data/ext/couchbase/core/transactions/active_transaction_record.hxx +2 -2
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +3 -0
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +1 -1
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.cxx +93 -0
- data/ext/couchbase/core/transactions/attempt_context_testing_hooks.hxx +48 -75
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.cxx +52 -0
- data/ext/couchbase/core/transactions/cleanup_testing_hooks.hxx +17 -31
- data/ext/couchbase/core/transactions/exceptions.hxx +12 -9
- data/ext/couchbase/core/transactions/internal/transaction_context.hxx +12 -12
- data/ext/couchbase/core/transactions/internal/transactions_cleanup.hxx +7 -1
- data/ext/couchbase/core/transactions/transaction_context.cxx +1 -0
- data/ext/couchbase/core/transactions/transactions_cleanup.cxx +144 -155
- data/ext/couchbase/core/utils/connection_string.cxx +27 -3
- data/ext/couchbase/core/utils/connection_string.hxx +3 -3
- data/ext/couchbase/core/utils/json.cxx +4 -1
- data/ext/couchbase/couchbase/analytics_error_context.hxx +143 -0
- data/ext/couchbase/couchbase/analytics_meta_data.hxx +155 -0
- data/ext/couchbase/couchbase/analytics_metrics.hxx +163 -0
- data/ext/couchbase/couchbase/analytics_options.hxx +359 -0
- data/ext/couchbase/couchbase/analytics_result.hxx +102 -0
- data/ext/couchbase/couchbase/analytics_scan_consistency.hxx +46 -0
- data/ext/couchbase/couchbase/analytics_status.hxx +41 -0
- data/ext/couchbase/couchbase/analytics_warning.hxx +85 -0
- data/ext/couchbase/couchbase/behavior_options.hxx +10 -1
- data/ext/couchbase/couchbase/boolean_field_query.hxx +77 -0
- data/ext/couchbase/couchbase/boolean_query.hxx +223 -0
- data/ext/couchbase/couchbase/cluster.hxx +75 -1
- data/ext/couchbase/couchbase/conjunction_query.hxx +88 -0
- data/ext/couchbase/couchbase/date_range.hxx +69 -0
- data/ext/couchbase/couchbase/date_range_facet.hxx +56 -0
- data/ext/couchbase/couchbase/date_range_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/date_range_query.hxx +265 -0
- data/ext/couchbase/couchbase/disjunction_query.hxx +109 -0
- data/ext/couchbase/couchbase/doc_id_query.hxx +111 -0
- data/ext/couchbase/couchbase/error_context.hxx +7 -6
- data/ext/couchbase/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- data/ext/couchbase/couchbase/fmt/analytics_status.hxx +76 -0
- data/ext/couchbase/couchbase/fmt/search_scan_consistency.hxx +49 -0
- data/ext/couchbase/couchbase/geo_bounding_box_query.hxx +107 -0
- data/ext/couchbase/couchbase/geo_distance_query.hxx +109 -0
- data/ext/couchbase/couchbase/geo_point.hxx +32 -0
- data/ext/couchbase/couchbase/geo_polygon_query.hxx +85 -0
- data/ext/couchbase/couchbase/highlight_style.hxx +45 -0
- data/ext/couchbase/couchbase/match_all_query.hxx +43 -0
- data/ext/couchbase/couchbase/match_none_query.hxx +43 -0
- data/ext/couchbase/couchbase/match_operator.hxx +45 -0
- data/ext/couchbase/couchbase/match_phrase_query.hxx +108 -0
- data/ext/couchbase/couchbase/match_query.hxx +163 -0
- data/ext/couchbase/couchbase/numeric_range.hxx +58 -0
- data/ext/couchbase/couchbase/numeric_range_facet.hxx +56 -0
- data/ext/couchbase/couchbase/numeric_range_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/numeric_range_query.hxx +143 -0
- data/ext/couchbase/couchbase/phrase_query.hxx +93 -0
- data/ext/couchbase/couchbase/prefix_query.hxx +82 -0
- data/ext/couchbase/couchbase/query_options.hxx +0 -1
- data/ext/couchbase/couchbase/query_string_query.hxx +72 -0
- data/ext/couchbase/couchbase/regexp_query.hxx +82 -0
- data/ext/couchbase/couchbase/scope.hxx +73 -0
- data/ext/couchbase/couchbase/search_date_range.hxx +68 -0
- data/ext/couchbase/couchbase/search_error_context.hxx +138 -0
- data/ext/couchbase/couchbase/search_facet.hxx +60 -0
- data/ext/couchbase/couchbase/search_facet_result.hxx +50 -0
- data/ext/couchbase/couchbase/search_meta_data.hxx +85 -0
- data/ext/couchbase/couchbase/search_metrics.hxx +127 -0
- data/ext/couchbase/couchbase/search_numeric_range.hxx +69 -0
- data/ext/couchbase/couchbase/search_options.hxx +509 -0
- data/ext/couchbase/couchbase/search_query.hxx +69 -0
- data/ext/couchbase/couchbase/search_result.hxx +77 -0
- data/ext/couchbase/couchbase/search_row.hxx +104 -0
- data/ext/couchbase/couchbase/search_row_location.hxx +55 -0
- data/ext/couchbase/couchbase/search_row_locations.hxx +86 -0
- data/ext/couchbase/couchbase/search_scan_consistency.hxx +34 -0
- data/ext/couchbase/couchbase/search_sort.hxx +58 -0
- data/ext/couchbase/couchbase/search_sort_field.hxx +117 -0
- data/ext/couchbase/couchbase/search_sort_field_missing.hxx +26 -0
- data/ext/couchbase/couchbase/search_sort_field_mode.hxx +27 -0
- data/ext/couchbase/couchbase/search_sort_field_type.hxx +28 -0
- data/ext/couchbase/couchbase/search_sort_id.hxx +60 -0
- data/ext/couchbase/couchbase/search_sort_score.hxx +60 -0
- data/ext/couchbase/couchbase/search_term_range.hxx +51 -0
- data/ext/couchbase/couchbase/security_options.hxx +3 -0
- data/ext/couchbase/couchbase/term_facet.hxx +48 -0
- data/ext/couchbase/couchbase/term_facet_result.hxx +55 -0
- data/ext/couchbase/couchbase/term_query.hxx +151 -0
- data/ext/couchbase/couchbase/term_range_query.hxx +142 -0
- data/ext/couchbase/couchbase/tracing/request_span.hxx +63 -0
- data/ext/couchbase/couchbase/tracing/request_tracer.hxx +2 -40
- data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +83 -4
- data/ext/couchbase/couchbase/transactions/attempt_context.hxx +68 -1
- data/ext/couchbase/couchbase/transactions/transaction_get_result.hxx +2 -0
- data/ext/couchbase/couchbase/transactions/transaction_keyspace.hxx +11 -1
- data/ext/couchbase/couchbase/transactions/transaction_options.hxx +79 -8
- data/ext/couchbase/couchbase/transactions/transaction_query_options.hxx +128 -15
- data/ext/couchbase/couchbase/transactions/transaction_query_result.hxx +4 -0
- data/ext/couchbase/couchbase/transactions/transaction_result.hxx +1 -1
- data/ext/couchbase/couchbase/transactions/transactions_cleanup_config.hxx +5 -3
- data/ext/couchbase/couchbase/transactions/transactions_config.hxx +9 -5
- data/ext/couchbase/couchbase/transactions/transactions_query_config.hxx +6 -3
- data/ext/couchbase/couchbase/transactions.hxx +34 -1
- data/ext/couchbase/couchbase/wildcard_query.hxx +83 -0
- data/ext/couchbase/test/CMakeLists.txt +8 -7
- data/ext/couchbase/test/benchmark_helper_integration.hxx +2 -2
- data/ext/couchbase/test/test_helper.hxx +6 -6
- data/ext/couchbase/test/test_integration_analytics.cxx +314 -16
- data/ext/couchbase/test/test_integration_collections.cxx +7 -3
- data/ext/couchbase/test/test_integration_connect.cxx +7 -3
- data/ext/couchbase/test/test_integration_crud.cxx +19 -2
- data/ext/couchbase/test/test_integration_diagnostics.cxx +11 -5
- data/ext/couchbase/test/test_integration_durability.cxx +12 -7
- data/ext/couchbase/test/test_integration_examples.cxx +324 -11
- data/ext/couchbase/test/test_integration_management.cxx +162 -94
- data/ext/couchbase/test/test_integration_query.cxx +68 -10
- data/ext/couchbase/test/test_integration_range_scan.cxx +12 -12
- data/ext/couchbase/test/test_integration_read_replica.cxx +48 -11
- data/ext/couchbase/test/test_integration_search.cxx +621 -0
- data/ext/couchbase/test/test_integration_subdoc.cxx +62 -11
- data/ext/couchbase/test/test_integration_tracer.cxx +5 -0
- data/ext/couchbase/test/test_integration_transcoders.cxx +13 -5
- data/ext/couchbase/test/{test_transaction_transaction_context.cxx → test_transaction_context.cxx} +1 -1
- data/ext/couchbase/test/test_transaction_examples.cxx +195 -0
- data/ext/couchbase/test/{test_transaction_transaction_simple.cxx → test_transaction_simple.cxx} +90 -5
- data/ext/couchbase/test/{test_transaction_transaction_simple_async.cxx → test_transaction_simple_async.cxx} +19 -21
- data/ext/couchbase/test/test_unit_config_profiles.cxx +13 -13
- data/ext/couchbase/test/test_unit_connection_string.cxx +35 -0
- data/ext/couchbase/test/test_unit_json_transcoder.cxx +4 -0
- data/ext/couchbase/test/test_unit_search.cxx +427 -0
- data/ext/couchbase/test/test_unit_transaction_utils.cxx +10 -1
- data/ext/couchbase/test/test_unit_utils.cxx +8 -4
- data/ext/couchbase/third_party/snappy/CMakeLists.txt +150 -27
- data/ext/couchbase/third_party/snappy/cmake/config.h.in +28 -24
- data/ext/couchbase/third_party/snappy/snappy-internal.h +189 -25
- data/ext/couchbase/third_party/snappy/snappy-sinksource.cc +26 -9
- data/ext/couchbase/third_party/snappy/snappy-sinksource.h +11 -11
- data/ext/couchbase/third_party/snappy/snappy-stubs-internal.cc +1 -1
- data/ext/couchbase/third_party/snappy/snappy-stubs-internal.h +227 -308
- data/ext/couchbase/third_party/snappy/snappy-stubs-public.h.in +0 -11
- data/ext/couchbase/third_party/snappy/snappy.cc +1176 -410
- data/ext/couchbase/third_party/snappy/snappy.h +19 -4
- data/ext/couchbase.cxx +85 -22
- data/ext/revisions.rb +3 -3
- data/lib/couchbase/authenticator.rb +0 -1
- data/lib/couchbase/cluster.rb +13 -13
- data/lib/couchbase/cluster_registry.rb +7 -2
- data/lib/couchbase/config_profiles.rb +1 -1
- data/lib/couchbase/configuration.rb +3 -4
- data/lib/couchbase/json_transcoder.rb +12 -5
- data/lib/couchbase/management/collection_query_index_manager.rb +54 -15
- data/lib/couchbase/management/query_index_manager.rb +70 -5
- data/lib/couchbase/options.rb +85 -2
- data/lib/couchbase/raw_binary_transcoder.rb +37 -0
- data/lib/couchbase/raw_json_transcoder.rb +38 -0
- data/lib/couchbase/raw_string_transcoder.rb +40 -0
- data/lib/couchbase/search_options.rb +163 -240
- data/lib/couchbase/transcoder_flags.rb +62 -0
- data/lib/couchbase/version.rb +1 -1
- metadata +151 -12
- data/ext/couchbase/core/CMakeLists.txt +0 -0
- /data/ext/couchbase/test/{test_transaction_transaction_public_async_api.cxx → test_transaction_public_async_api.cxx} +0 -0
- /data/ext/couchbase/test/{test_transaction_transaction_public_blocking_api.cxx → test_transaction_public_blocking_api.cxx} +0 -0
@@ -28,33 +28,6 @@ class attempt_context;
|
|
28
28
|
using error_func1 = std::function<std::optional<error_class>(attempt_context*)>;
|
29
29
|
using error_func2 = std::function<std::optional<error_class>(attempt_context*, const std::string&)>;
|
30
30
|
|
31
|
-
namespace
|
32
|
-
{
|
33
|
-
std::optional<error_class>
|
34
|
-
noop_1(attempt_context*)
|
35
|
-
{
|
36
|
-
return {};
|
37
|
-
}
|
38
|
-
|
39
|
-
std::optional<error_class>
|
40
|
-
noop_2(attempt_context*, const std::string&)
|
41
|
-
{
|
42
|
-
return {};
|
43
|
-
}
|
44
|
-
|
45
|
-
std::optional<const std::string>
|
46
|
-
noop_3(attempt_context*)
|
47
|
-
{
|
48
|
-
return {};
|
49
|
-
}
|
50
|
-
|
51
|
-
bool
|
52
|
-
noop_4(attempt_context*, const std::string&, std::optional<const std::string>)
|
53
|
-
{
|
54
|
-
return false;
|
55
|
-
}
|
56
|
-
} // namespace
|
57
|
-
|
58
31
|
static const std::string STAGE_ROLLBACK = "rollback";
|
59
32
|
static const std::string STAGE_GET = "get";
|
60
33
|
static const std::string STAGE_INSERT = "insert";
|
@@ -91,55 +64,55 @@ static const std::string STAGE_QUERY_KV_INSERT = "queryKvInsert";
|
|
91
64
|
* about your use-case: we are always open to adding good ideas into the transactions library.
|
92
65
|
*/
|
93
66
|
struct attempt_context_testing_hooks {
|
94
|
-
error_func1 before_atr_commit
|
95
|
-
error_func1 before_atr_commit_ambiguity_resolution
|
96
|
-
error_func1 after_atr_commit
|
97
|
-
error_func2 before_doc_committed
|
98
|
-
error_func2 before_removing_doc_during_staged_insert
|
99
|
-
error_func2 before_rollback_delete_inserted
|
100
|
-
error_func2 after_doc_committed_before_saving_cas
|
101
|
-
error_func2 after_doc_committed
|
102
|
-
error_func2 before_staged_insert
|
103
|
-
error_func2 before_staged_remove
|
104
|
-
error_func2 before_staged_replace
|
105
|
-
error_func2 before_doc_removed
|
106
|
-
error_func2 before_doc_rolled_back
|
107
|
-
error_func2 after_doc_removed_pre_retry
|
108
|
-
error_func2 after_doc_removed_post_retry
|
109
|
-
error_func2 after_get_complete
|
110
|
-
error_func2 after_staged_replace_complete_before_cas_saved
|
111
|
-
error_func2 after_staged_replace_complete
|
112
|
-
error_func2 after_staged_remove_complete
|
113
|
-
error_func2 after_staged_insert_complete
|
114
|
-
error_func2 after_rollback_replace_or_remove
|
115
|
-
error_func2 after_rollback_delete_inserted
|
116
|
-
error_func2 before_check_atr_entry_for_blocking_doc
|
117
|
-
error_func2 before_doc_get
|
118
|
-
error_func2 before_get_doc_in_exists_during_staged_insert
|
119
|
-
error_func2 before_query
|
120
|
-
error_func2 after_query
|
121
|
-
error_func2 before_remove_staged_insert
|
122
|
-
error_func2 after_remove_staged_insert
|
123
|
-
|
124
|
-
error_func1 after_docs_committed
|
125
|
-
error_func1 after_docs_removed
|
126
|
-
error_func1 after_atr_pending
|
127
|
-
error_func1 before_atr_pending
|
128
|
-
error_func1 before_atr_complete
|
129
|
-
error_func1 before_atr_rolled_back
|
130
|
-
error_func1 after_atr_complete
|
131
|
-
error_func1 before_get_atr_for_abort
|
132
|
-
error_func1 before_atr_aborted
|
133
|
-
error_func1 after_atr_aborted
|
134
|
-
error_func1 after_atr_rolled_back
|
135
|
-
|
136
|
-
std::function<std::optional<const std::string>(attempt_context*)> random_atr_id_for_vbucket
|
137
|
-
|
138
|
-
std::function<bool(attempt_context*, const std::string&, std::optional<const std::string>)> has_expired_client_side
|
67
|
+
error_func1 before_atr_commit;
|
68
|
+
error_func1 before_atr_commit_ambiguity_resolution;
|
69
|
+
error_func1 after_atr_commit;
|
70
|
+
error_func2 before_doc_committed;
|
71
|
+
error_func2 before_removing_doc_during_staged_insert;
|
72
|
+
error_func2 before_rollback_delete_inserted;
|
73
|
+
error_func2 after_doc_committed_before_saving_cas;
|
74
|
+
error_func2 after_doc_committed;
|
75
|
+
error_func2 before_staged_insert;
|
76
|
+
error_func2 before_staged_remove;
|
77
|
+
error_func2 before_staged_replace;
|
78
|
+
error_func2 before_doc_removed;
|
79
|
+
error_func2 before_doc_rolled_back;
|
80
|
+
error_func2 after_doc_removed_pre_retry;
|
81
|
+
error_func2 after_doc_removed_post_retry;
|
82
|
+
error_func2 after_get_complete;
|
83
|
+
error_func2 after_staged_replace_complete_before_cas_saved;
|
84
|
+
error_func2 after_staged_replace_complete;
|
85
|
+
error_func2 after_staged_remove_complete;
|
86
|
+
error_func2 after_staged_insert_complete;
|
87
|
+
error_func2 after_rollback_replace_or_remove;
|
88
|
+
error_func2 after_rollback_delete_inserted;
|
89
|
+
error_func2 before_check_atr_entry_for_blocking_doc;
|
90
|
+
error_func2 before_doc_get;
|
91
|
+
error_func2 before_get_doc_in_exists_during_staged_insert;
|
92
|
+
error_func2 before_query;
|
93
|
+
error_func2 after_query;
|
94
|
+
error_func2 before_remove_staged_insert;
|
95
|
+
error_func2 after_remove_staged_insert;
|
96
|
+
|
97
|
+
error_func1 after_docs_committed;
|
98
|
+
error_func1 after_docs_removed;
|
99
|
+
error_func1 after_atr_pending;
|
100
|
+
error_func1 before_atr_pending;
|
101
|
+
error_func1 before_atr_complete;
|
102
|
+
error_func1 before_atr_rolled_back;
|
103
|
+
error_func1 after_atr_complete;
|
104
|
+
error_func1 before_get_atr_for_abort;
|
105
|
+
error_func1 before_atr_aborted;
|
106
|
+
error_func1 after_atr_aborted;
|
107
|
+
error_func1 after_atr_rolled_back;
|
108
|
+
|
109
|
+
std::function<std::optional<const std::string>(attempt_context*)> random_atr_id_for_vbucket;
|
110
|
+
|
111
|
+
std::function<bool(attempt_context*, const std::string&, std::optional<const std::string>)> has_expired_client_side;
|
112
|
+
|
113
|
+
attempt_context_testing_hooks();
|
139
114
|
|
140
115
|
// needed for unique_ptr<attempt_context_testing_hooks> in transaction_config, with a forward declaration.
|
141
|
-
~attempt_context_testing_hooks()
|
142
|
-
{
|
143
|
-
}
|
116
|
+
~attempt_context_testing_hooks() = default;
|
144
117
|
};
|
145
118
|
} // namespace couchbase::core::transactions
|
@@ -0,0 +1,52 @@
|
|
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 "cleanup_testing_hooks.hxx"
|
18
|
+
|
19
|
+
namespace couchbase::core::transactions
|
20
|
+
{
|
21
|
+
namespace
|
22
|
+
{
|
23
|
+
inline std::optional<couchbase::core::transactions::error_class>
|
24
|
+
noop1(const std::string&)
|
25
|
+
{
|
26
|
+
return {};
|
27
|
+
}
|
28
|
+
|
29
|
+
inline std::optional<couchbase::core::transactions::error_class>
|
30
|
+
noop2()
|
31
|
+
{
|
32
|
+
return {};
|
33
|
+
}
|
34
|
+
} // namespace
|
35
|
+
|
36
|
+
cleanup_testing_hooks::cleanup_testing_hooks()
|
37
|
+
: before_commit_doc{ noop1 }
|
38
|
+
, before_doc_get{ noop1 }
|
39
|
+
, before_remove_doc_staged_for_removal{ noop1 }
|
40
|
+
, before_remove_doc{ noop1 }
|
41
|
+
, before_atr_get{ noop1 }
|
42
|
+
, before_remove_links{ noop1 }
|
43
|
+
, before_atr_remove{ noop2 }
|
44
|
+
, on_cleanup_docs_completed{ noop2 }
|
45
|
+
, on_cleanup_completed{ noop2 }
|
46
|
+
, client_record_before_create{ noop1 }
|
47
|
+
, client_record_before_get{ noop1 }
|
48
|
+
, client_record_before_update{ noop1 }
|
49
|
+
, client_record_before_remove_client{ noop1 }
|
50
|
+
{
|
51
|
+
}
|
52
|
+
} // namespace couchbase::core::transactions
|
@@ -18,52 +18,38 @@
|
|
18
18
|
#include "core/transactions/error_class.hxx"
|
19
19
|
|
20
20
|
#include <functional>
|
21
|
+
#include <optional>
|
21
22
|
#include <string>
|
22
23
|
|
23
24
|
namespace couchbase::core::transactions
|
24
25
|
{
|
25
26
|
using error_func3 = std::function<std::optional<error_class>(const std::string&)>;
|
26
27
|
using error_func4 = std::function<std::optional<error_class>(void)>;
|
27
|
-
namespace
|
28
|
-
{
|
29
|
-
std::optional<couchbase::core::transactions::error_class>
|
30
|
-
noop1(const std::string&)
|
31
|
-
{
|
32
|
-
return {};
|
33
|
-
}
|
34
|
-
std::optional<couchbase::core::transactions::error_class>
|
35
|
-
noop2()
|
36
|
-
{
|
37
|
-
return {};
|
38
|
-
}
|
39
|
-
|
40
|
-
} // namespace
|
41
28
|
|
42
29
|
/**
|
43
30
|
* Hooks purely for testing purposes. If you're an end-user looking at these for any reason, then please contact us first
|
44
31
|
* about your use-case: we are always open to adding good ideas into the transactions library.
|
45
32
|
*/
|
46
33
|
struct cleanup_testing_hooks {
|
47
|
-
error_func3 before_commit_doc
|
48
|
-
error_func3 before_doc_get
|
49
|
-
error_func3 before_remove_doc_staged_for_removal
|
50
|
-
error_func3 before_remove_doc
|
51
|
-
error_func3 before_atr_get
|
52
|
-
error_func3 before_remove_links
|
34
|
+
error_func3 before_commit_doc;
|
35
|
+
error_func3 before_doc_get;
|
36
|
+
error_func3 before_remove_doc_staged_for_removal;
|
37
|
+
error_func3 before_remove_doc;
|
38
|
+
error_func3 before_atr_get;
|
39
|
+
error_func3 before_remove_links;
|
53
40
|
|
54
|
-
error_func4 before_atr_remove
|
41
|
+
error_func4 before_atr_remove;
|
55
42
|
|
56
|
-
error_func4 on_cleanup_docs_completed
|
57
|
-
error_func4 on_cleanup_completed
|
43
|
+
error_func4 on_cleanup_docs_completed;
|
44
|
+
error_func4 on_cleanup_completed;
|
58
45
|
|
59
|
-
error_func3 client_record_before_create
|
60
|
-
error_func3 client_record_before_get
|
61
|
-
error_func3 client_record_before_update
|
62
|
-
error_func3 client_record_before_remove_client
|
46
|
+
error_func3 client_record_before_create;
|
47
|
+
error_func3 client_record_before_get;
|
48
|
+
error_func3 client_record_before_update;
|
49
|
+
error_func3 client_record_before_remove_client;
|
63
50
|
|
51
|
+
cleanup_testing_hooks();
|
64
52
|
// needed for unique_ptr<cleanup_testing_hooks> in transaction_config, with a forward declaration.
|
65
|
-
~cleanup_testing_hooks()
|
66
|
-
{
|
67
|
-
}
|
53
|
+
~cleanup_testing_hooks() = default;
|
68
54
|
};
|
69
|
-
} // namespace couchbase::core::transactions
|
55
|
+
} // namespace couchbase::core::transactions
|
@@ -16,11 +16,14 @@
|
|
16
16
|
|
17
17
|
#pragma once
|
18
18
|
|
19
|
-
#include
|
19
|
+
#include "core/error_context/query.hxx"
|
20
|
+
#include "error_class.hxx"
|
21
|
+
|
20
22
|
#include <couchbase/error_codes.hxx>
|
21
23
|
#include <couchbase/transactions/transaction_result.hxx>
|
22
|
-
|
24
|
+
|
23
25
|
#include <stdexcept>
|
26
|
+
#include <utility>
|
24
27
|
|
25
28
|
namespace couchbase::core::transactions
|
26
29
|
{
|
@@ -135,7 +138,7 @@ class op_exception : public std::runtime_error
|
|
135
138
|
transaction_op_error_context ctx_;
|
136
139
|
|
137
140
|
public:
|
138
|
-
op_exception(transaction_op_error_context ctx, external_exception cause = COUCHBASE_EXCEPTION)
|
141
|
+
explicit op_exception(transaction_op_error_context ctx, external_exception cause = COUCHBASE_EXCEPTION)
|
139
142
|
: std::runtime_error(ctx.ec().message())
|
140
143
|
, cause_(cause)
|
141
144
|
, ctx_(std::move(ctx))
|
@@ -157,7 +160,7 @@ class document_not_found : public op_exception
|
|
157
160
|
{
|
158
161
|
public:
|
159
162
|
explicit document_not_found(transaction_op_error_context ctx)
|
160
|
-
: op_exception(ctx, DOCUMENT_NOT_FOUND_EXCEPTION)
|
163
|
+
: op_exception(std::move(ctx), DOCUMENT_NOT_FOUND_EXCEPTION)
|
161
164
|
{
|
162
165
|
}
|
163
166
|
};
|
@@ -166,7 +169,7 @@ class document_exists : public op_exception
|
|
166
169
|
{
|
167
170
|
public:
|
168
171
|
explicit document_exists(transaction_op_error_context ctx)
|
169
|
-
: op_exception(ctx, DOCUMENT_EXISTS_EXCEPTION)
|
172
|
+
: op_exception(std::move(ctx), DOCUMENT_EXISTS_EXCEPTION)
|
170
173
|
{
|
171
174
|
}
|
172
175
|
};
|
@@ -175,7 +178,7 @@ class query_attempt_not_found : public op_exception
|
|
175
178
|
{
|
176
179
|
public:
|
177
180
|
query_attempt_not_found(transaction_op_error_context ctx)
|
178
|
-
: op_exception(ctx)
|
181
|
+
: op_exception(std::move(ctx))
|
179
182
|
{
|
180
183
|
}
|
181
184
|
};
|
@@ -184,7 +187,7 @@ class query_cas_mismatch : public op_exception
|
|
184
187
|
{
|
185
188
|
public:
|
186
189
|
query_cas_mismatch(transaction_op_error_context ctx)
|
187
|
-
: op_exception(ctx)
|
190
|
+
: op_exception(std::move(ctx))
|
188
191
|
{
|
189
192
|
}
|
190
193
|
};
|
@@ -193,7 +196,7 @@ class query_attempt_expired : public op_exception
|
|
193
196
|
{
|
194
197
|
public:
|
195
198
|
query_attempt_expired(transaction_op_error_context ctx)
|
196
|
-
: op_exception(ctx)
|
199
|
+
: op_exception(std::move(ctx))
|
197
200
|
{
|
198
201
|
}
|
199
202
|
};
|
@@ -202,7 +205,7 @@ class query_parsing_failure : public op_exception
|
|
202
205
|
{
|
203
206
|
public:
|
204
207
|
query_parsing_failure(transaction_op_error_context ctx)
|
205
|
-
: op_exception(ctx, PARSING_FAILURE)
|
208
|
+
: op_exception(std::move(ctx), PARSING_FAILURE)
|
206
209
|
{
|
207
210
|
}
|
208
211
|
};
|
@@ -49,30 +49,29 @@ class transaction_context
|
|
49
49
|
|
50
50
|
[[nodiscard]] std::size_t num_attempts() const
|
51
51
|
{
|
52
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
52
53
|
return attempts_.size();
|
53
54
|
}
|
54
|
-
[[nodiscard]] const std::vector<transaction_attempt>& attempts() const
|
55
|
-
{
|
56
|
-
return attempts_;
|
57
|
-
}
|
58
|
-
[[nodiscard]] std::vector<transaction_attempt>& attempts()
|
59
|
-
{
|
60
|
-
return const_cast<std::vector<transaction_attempt>&>(const_cast<const transaction_context*>(this)->attempts());
|
61
|
-
}
|
62
55
|
[[nodiscard]] const transaction_attempt& current_attempt() const
|
63
56
|
{
|
57
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
64
58
|
if (attempts_.empty()) {
|
65
59
|
throw std::runtime_error("transaction context has no attempts yet");
|
66
60
|
}
|
67
61
|
return attempts_.back();
|
68
62
|
}
|
69
|
-
[[nodiscard]] transaction_attempt& current_attempt()
|
70
|
-
{
|
71
|
-
return const_cast<transaction_attempt&>(const_cast<const transaction_context*>(this)->current_attempt());
|
72
|
-
}
|
73
63
|
|
74
64
|
void add_attempt();
|
75
65
|
|
66
|
+
void current_attempt_state(attempt_state s)
|
67
|
+
{
|
68
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
69
|
+
if (attempts_.empty()) {
|
70
|
+
throw std::runtime_error("transaction_context has no attempts yet");
|
71
|
+
}
|
72
|
+
attempts_.back().state = s;
|
73
|
+
}
|
74
|
+
|
76
75
|
[[nodiscard]] std::shared_ptr<core::cluster> cluster_ref()
|
77
76
|
{
|
78
77
|
return transactions_.cluster_ref();
|
@@ -191,6 +190,7 @@ class transaction_context
|
|
191
190
|
std::string atr_collection_;
|
192
191
|
transactions_cleanup& cleanup_;
|
193
192
|
std::shared_ptr<attempt_context_impl> current_attempt_context_;
|
193
|
+
mutable std::mutex mutex_;
|
194
194
|
|
195
195
|
std::unique_ptr<exp_delay> delay_;
|
196
196
|
};
|
@@ -145,6 +145,12 @@ class transactions_cleanup
|
|
145
145
|
|
146
146
|
void attempts_loop();
|
147
147
|
|
148
|
+
bool is_running()
|
149
|
+
{
|
150
|
+
std::unique_lock<std::mutex> lock(mutex_);
|
151
|
+
return running_;
|
152
|
+
}
|
153
|
+
|
148
154
|
template<class R, class P>
|
149
155
|
bool interruptable_wait(std::chrono::duration<R, P> time);
|
150
156
|
|
@@ -153,7 +159,7 @@ class transactions_cleanup
|
|
153
159
|
void create_client_record(const couchbase::transactions::transaction_keyspace& keyspace);
|
154
160
|
const atr_cleanup_stats handle_atr_cleanup(const core::document_id& atr_id,
|
155
161
|
std::vector<transactions_cleanup_attempt>* result = nullptr);
|
156
|
-
|
162
|
+
bool running_{ false };
|
157
163
|
};
|
158
164
|
} // namespace transactions
|
159
165
|
} // namespace couchbase::core
|