diff --git a/core/meta/features.hxx b/core/meta/features.hxx index 7aea7f362..580315032 100644 --- a/core/meta/features.hxx +++ b/core/meta/features.hxx @@ -79,6 +79,12 @@ */ #define COUCHBASE_CXX_CLIENT_HAS_CORE_CLUSTER_HIDDEN 1 +/** + * expiration_time has been renamed to timeout in transactions_options and transactions_config + * kv_timeout removed from transactions_options and transactions_config + */ +#define COUCHBASE_CXX_CLIENT_TRANSACTIONS_OPTIONS_HAVE_TIMEOUT 1 + /** * Search index management is accessible from the public API * couchbase::cluster::search_indexes() support diff --git a/core/origin.cxx b/core/origin.cxx index a5da80393..01ecd7f50 100644 --- a/core/origin.cxx +++ b/core/origin.cxx @@ -168,7 +168,7 @@ struct traits { static void assign(tao::json::basic_value& v, const couchbase::transactions::transactions_config::built& o) { v = { - { "expiration_time", o.expiration_time }, + { "timeout", o.timeout }, { "durability_level", o.level }, { "query_config", @@ -186,9 +186,6 @@ struct traits { }, }, }; - if (const auto& p = o.kv_timeout; p.has_value()) { - v["key_value_timeout"] = p.value(); - } if (const auto& p = o.metadata_collection; p.has_value()) { v["metadata_collection"] = { { "bucket", p.value().bucket }, diff --git a/core/transactions/active_transaction_record.hxx b/core/transactions/active_transaction_record.hxx index 348200329..72bf2cfd0 100644 --- a/core/transactions/active_transaction_record.hxx +++ b/core/transactions/active_transaction_record.hxx @@ -35,7 +35,6 @@ namespace couchbase::core::transactions class active_transaction_record { public: - // TODO: we should get the kv_timeout and put it in the request (pass in the transactions_config) template static void get_atr(const core::cluster& cluster, const core::document_id& atr_id, Callback&& cb) { diff --git a/core/transactions/atr_cleanup_entry.cxx b/core/transactions/atr_cleanup_entry.cxx index feda0cdb6..989cb1d78 100644 --- a/core/transactions/atr_cleanup_entry.cxx +++ b/core/transactions/atr_cleanup_entry.cxx @@ -191,7 +191,6 @@ atr_cleanup_entry::do_per_doc(std::vector docs, } .specs(); req.access_deleted = true; - wrap_request(req, cleanup_->config()); // now a blocking lookup_in... auto barrier = std::make_shared>(); cleanup_->cluster_ref().execute( @@ -255,10 +254,9 @@ atr_cleanup_entry::commit_docs(std::optional> docs, dura core::operations::insert_request req{ doc.id(), content }; auto barrier = std::make_shared>(); auto f = barrier->get_future(); - cleanup_->cluster_ref().execute(wrap_durable_request(req, cleanup_->config(), dl), - [barrier](core::operations::insert_response resp) { - barrier->set_value(result::create_from_mutation_response(resp)); - }); + cleanup_->cluster_ref().execute(wrap_durable_request(req, dl), [barrier](core::operations::insert_response resp) { + barrier->set_value(result::create_from_mutation_response(resp)); + }); wrap_operation_future(f); } else { core::operations::mutate_in_request req{ doc.id() }; @@ -270,7 +268,7 @@ atr_cleanup_entry::commit_docs(std::optional> docs, dura .specs(); req.cas = doc.cas(); req.store_semantics = couchbase::store_semantics::replace; - wrap_durable_request(req, cleanup_->config(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute(req, [barrier](core::operations::mutate_in_response resp) { @@ -303,7 +301,7 @@ atr_cleanup_entry::remove_docs(std::optional> docs, dura .specs(); req.cas = doc.cas(); req.access_deleted = true; - wrap_durable_request(req, cleanup_->config(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute(req, [barrier](core::operations::mutate_in_response resp) { @@ -313,7 +311,7 @@ atr_cleanup_entry::remove_docs(std::optional> docs, dura } else { core::operations::remove_request req{ doc.id() }; req.cas = doc.cas(); - wrap_durable_request(req, cleanup_->config(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute(req, [barrier](core::operations::remove_response resp) { @@ -338,7 +336,7 @@ atr_cleanup_entry::remove_docs_staged_for_removal(std::optionalconfig(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute(req, [barrier](core::operations::remove_response resp) { @@ -372,7 +370,7 @@ atr_cleanup_entry::remove_txn_links(std::optional> docs, .specs(); req.access_deleted = true; req.cas = doc.cas(); - wrap_durable_request(req, cleanup_->config(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute( @@ -399,7 +397,7 @@ atr_cleanup_entry::cleanup_entry(durability_level dl) } mut_specs.push_back(couchbase::mutate_in_specs::remove("attempts." + atr_entry_->attempt_id()).xattr()); req.specs = mut_specs.specs(); - wrap_durable_request(req, cleanup_->config(), dl); + wrap_durable_request(req, dl); auto barrier = std::make_shared>(); auto f = barrier->get_future(); cleanup_->cluster_ref().execute( diff --git a/core/transactions/attempt_context_impl.cxx b/core/transactions/attempt_context_impl.cxx index 8cab82f85..3d2cbac36 100644 --- a/core/transactions/attempt_context_impl.cxx +++ b/core/transactions/attempt_context_impl.cxx @@ -340,8 +340,7 @@ attempt_context_impl::replace_raw(const transaction_get_result& document, const } if (existing_sm != nullptr && existing_sm->type() == staged_mutation_type::INSERT) { CB_ATTEMPT_CTX_LOG_DEBUG(this, "found existing INSERT of {} while replacing", document); - exp_delay delay( - std::chrono::milliseconds(5), std::chrono::milliseconds(300), overall_.config().expiration_time); + exp_delay delay(std::chrono::milliseconds(5), std::chrono::milliseconds(300), overall_.config().timeout); create_staged_insert(document.id(), content, existing_sm->doc().cas().value(), delay, op_id, std::move(cb)); return; } @@ -478,7 +477,7 @@ attempt_context_impl::insert_raw(const core::document_id& id, const std::vector< return create_staged_replace(existing_sm->doc(), content, op_id, std::move(cb)); } uint64_t cas = 0; - exp_delay delay(std::chrono::milliseconds(5), std::chrono::milliseconds(300), overall_.config().expiration_time); + exp_delay delay(std::chrono::milliseconds(5), std::chrono::milliseconds(300), overall_.config().timeout); create_staged_insert(id, content, cas, delay, op_id, std::move(cb)); }); } catch (const std::exception& e) { @@ -764,8 +763,9 @@ attempt_context_impl::query_begin_work(std::optional query_context, txdata["state"] = tao::json::empty_object; txdata["state"]["timeLeftMs"] = overall_.remaining().count() / 1000000; txdata["config"] = tao::json::empty_object; + auto [ec, origin] = overall_.cluster_ref().origin(); txdata["config"]["kvTimeoutMs"] = - overall_.config().kv_timeout ? overall_.config().kv_timeout->count() : core::timeout_defaults::key_value_timeout.count(); + (ec) ? core::timeout_defaults::key_value_durable_timeout.count() : origin.options().key_value_durable_timeout.count(); txdata["config"]["numAtrs"] = 1024; opts.raw("numatrs", jsonify(1024)); txdata["config"]["durabilityLevel"] = durability_level_to_string(overall_.config().level); @@ -1496,7 +1496,6 @@ attempt_context_impl::atr_commit_ambiguity_resolution() std::string prefix(ATR_FIELD_ATTEMPTS + "." + id() + "."); core::operations::lookup_in_request req{ atr_id_.value() }; req.specs = lookup_in_specs{ lookup_in_specs::get(prefix + ATR_FIELD_STATUS).xattr() }.specs(); - wrap_request(req, overall_.config()); auto barrier = std::make_shared>(); auto f = barrier->get_future(); overall_.cluster_ref().execute( @@ -1935,10 +1934,10 @@ attempt_context_impl::set_atr_pending_locked(const core::document_id& id, std::u CB_ATTEMPT_CTX_LOG_DEBUG(this, "updating atr {}", atr_id_.value()); std::chrono::nanoseconds remaining = overall_.remaining(); - // This bounds the value to [0-expirationTime]. It should always be in this range, this is just to protect + // This bounds the value to [0-timeout]. It should always be in this range, this is just to protect // against the application clock changing. - long remaining_bounded_nanos = std::max(std::min(remaining.count(), overall_.config().expiration_time.count()), - static_cast(0)); + long remaining_bounded_nanos = + std::max(std::min(remaining.count(), overall_.config().timeout.count()), static_cast(0)); long remaining_bounded_msecs = remaining_bounded_nanos / 1'000'000; core::operations::mutate_in_request req{ atr_id_.value() }; @@ -2176,7 +2175,6 @@ attempt_context_impl::get_doc( } .specs(); req.access_deleted = true; - wrap_request(req, overall_.config()); try { overall_.cluster_ref().execute(req, [this, id, cb = std::move(cb)](core::operations::lookup_in_response resp) { auto ec = error_class_from_response(resp); diff --git a/core/transactions/internal/utils.hxx b/core/transactions/internal/utils.hxx index 17c8d9a89..0b4303371 100644 --- a/core/transactions/internal/utils.hxx +++ b/core/transactions/internal/utils.hxx @@ -57,30 +57,18 @@ operator<<(OStream& os, const core::document_id& id) return os; } -template -T& -wrap_request(T&& req, const couchbase::transactions::transactions_config::built& config) -{ - if (config.kv_timeout) { - req.timeout = config.kv_timeout.value(); - } - return req; -} - template T& wrap_durable_request(T&& req, const couchbase::transactions::transactions_config::built& config) { - wrap_request(req, config); req.durability_level = config.level; return req; } template T& -wrap_durable_request(T&& req, const couchbase::transactions::transactions_config::built& config, durability_level level) +wrap_durable_request(T&& req, durability_level level) { - wrap_request(req, config); req.durability_level = level; return req; } diff --git a/core/transactions/transaction_context.cxx b/core/transactions/transaction_context.cxx index 2bc4b8c54..17b16f61a 100644 --- a/core/transactions/transaction_context.cxx +++ b/core/transactions/transaction_context.cxx @@ -32,7 +32,7 @@ transaction_context::transaction_context(transactions& txns, const couchbase::tr , config_(config.apply(txns.config())) , deferred_elapsed_(0) , cleanup_(txns.cleanup()) - , delay_(new exp_delay(std::chrono::milliseconds(1), std::chrono::milliseconds(100), 2 * config_.expiration_time)) + , delay_(new exp_delay(std::chrono::milliseconds(1), std::chrono::milliseconds(100), 2 * config_.timeout)) { // add metadata_collection to cleanup, if present if (config_.metadata_collection) { @@ -54,7 +54,7 @@ transaction_context::remaining() const { const auto& now = std::chrono::steady_clock::now(); auto expired_nanos = std::chrono::duration_cast(now - start_time_client_) + deferred_elapsed_; - return config_.expiration_time - expired_nanos; + return config_.timeout - expired_nanos; } [[nodiscard]] bool @@ -64,7 +64,7 @@ transaction_context::has_expired_client_side() const auto& now = std::chrono::steady_clock::now(); auto expired_nanos = std::chrono::duration_cast(now - start_time_client_) + deferred_elapsed_; auto expired_millis = std::chrono::duration_cast(expired_nanos); - bool is_expired = expired_nanos > config_.expiration_time; + bool is_expired = expired_nanos > config_.timeout; if (is_expired) { CB_ATTEMPT_CTX_LOG_INFO(current_attempt_context_, "has expired client side (now={}ns, start={}ns, deferred_elapsed={}ns, expired={}ns ({}ms), config={}ms)", @@ -73,7 +73,7 @@ transaction_context::has_expired_client_side() deferred_elapsed_.count(), expired_nanos.count(), expired_millis.count(), - std::chrono::duration_cast(config_.expiration_time).count()); + std::chrono::duration_cast(config_.timeout).count()); } return is_expired; } diff --git a/core/transactions/transaction_options.cxx b/core/transactions/transaction_options.cxx index 39ede188b..b56256d84 100644 --- a/core/transactions/transaction_options.cxx +++ b/core/transactions/transaction_options.cxx @@ -30,8 +30,7 @@ transaction_options::apply(const transactions_config::built& conf) const query_config.scan_consistency = *scan_consistency_; } return { durability_.value_or(conf.level), - expiration_time_.value_or(conf.expiration_time), - kv_timeout_ ? kv_timeout_ : conf.kv_timeout, + timeout_.value_or(conf.timeout), attempt_context_hooks_ ? attempt_context_hooks_ : conf.attempt_context_hooks, cleanup_hooks_ ? cleanup_hooks_ : conf.cleanup_hooks, metadata_collection_ ? metadata_collection_ : conf.metadata_collection, @@ -80,23 +79,10 @@ transaction_options::scan_consistency() const return scan_consistency_; } -transaction_options& -transaction_options::kv_timeout(std::chrono::milliseconds kv_timeout) -{ - kv_timeout_ = kv_timeout; - return *this; -} - -std::optional -transaction_options::kv_timeout() -{ - return kv_timeout_; -} - std::optional -transaction_options::expiration_time() +transaction_options::timeout() { - return expiration_time_; + return timeout_; } transaction_options& diff --git a/core/transactions/transactions.cxx b/core/transactions/transactions.cxx index 8a280834e..965441154 100644 --- a/core/transactions/transactions.cxx +++ b/core/transactions/transactions.cxx @@ -77,7 +77,7 @@ wrap_run(transactions& txns, const couchbase::transactions::transaction_options& while (attempts++ < max_attempts) { // NOTE: new_attempt_context has the exponential backoff built in. So, after // the first time it is called, it has a 1ms delay, then 2ms, etc... capped at 100ms - // until (for now) a timeout is reached (2x the expiration_time). Soon, will build in + // until (for now) a timeout is reached (2x the timeout). Soon, will build in // a max attempts instead. In any case, the timeout occurs in the logic - adding // a max attempts or timeout is just in case a bug prevents timeout, etc... overall.new_attempt_context(); diff --git a/core/transactions/transactions_cleanup.cxx b/core/transactions/transactions_cleanup.cxx index 6127b8b23..1b59f6e0d 100644 --- a/core/transactions/transactions_cleanup.cxx +++ b/core/transactions/transactions_cleanup.cxx @@ -283,7 +283,6 @@ transactions_cleanup::get_active_clients(const couchbase::transactions::transact lookup_in_specs::get(subdoc::lookup_in_macro::vbucket).xattr(), } .specs(); - wrap_request(req, config_); auto barrier = std::make_shared>(); auto f = barrier->get_future(); auto ec = config_.cleanup_hooks->client_record_before_get(keyspace.bucket); diff --git a/core/transactions/transactions_config.cxx b/core/transactions/transactions_config.cxx index 77d1b12ba..3becbb1f8 100644 --- a/core/transactions/transactions_config.cxx +++ b/core/transactions/transactions_config.cxx @@ -26,7 +26,7 @@ namespace couchbase::transactions transactions_config::transactions_config() : level_(couchbase::durability_level::majority) - , expiration_time_(std::chrono::seconds(15)) + , timeout_(std::chrono::seconds(15)) , attempt_context_hooks_(new core::transactions::attempt_context_testing_hooks()) , cleanup_hooks_(new core::transactions::cleanup_testing_hooks()) { @@ -36,7 +36,7 @@ transactions_config::~transactions_config() = default; transactions_config::transactions_config(transactions_config&& c) noexcept : level_(c.level_) - , expiration_time_(c.expiration_time_) + , timeout_(c.timeout_) , attempt_context_hooks_(c.attempt_context_hooks_) , cleanup_hooks_(c.cleanup_hooks_) , metadata_collection_(std::move(c.metadata_collection_)) @@ -47,7 +47,7 @@ transactions_config::transactions_config(transactions_config&& c) noexcept transactions_config::transactions_config(const transactions_config& config) : level_(config.durability_level()) - , expiration_time_(config.expiration_time()) + , timeout_(config.timeout()) , attempt_context_hooks_(std::make_shared(config.attempt_context_hooks())) , cleanup_hooks_(std::make_shared(config.cleanup_hooks())) , metadata_collection_(config.metadata_collection()) @@ -61,7 +61,7 @@ transactions_config::operator=(const transactions_config& c) { if (this != &c) { level_ = c.level_; - expiration_time_ = c.expiration_time_; + timeout_ = c.timeout_; attempt_context_hooks_ = c.attempt_context_hooks_; cleanup_hooks_ = c.cleanup_hooks_; query_config_ = c.query_config_; @@ -74,8 +74,9 @@ transactions_config::operator=(const transactions_config& c) transactions_config::built transactions_config::build() const { - return { level_, expiration_time_, kv_timeout_, attempt_context_hooks_, - cleanup_hooks_, metadata_collection_, query_config_.build(), cleanup_config_.build() }; + return { + level_, timeout_, attempt_context_hooks_, cleanup_hooks_, metadata_collection_, query_config_.build(), cleanup_config_.build() + }; } } // namespace couchbase::transactions diff --git a/couchbase/transactions/transaction_options.hxx b/couchbase/transactions/transaction_options.hxx index c17e58633..3db1ec5e7 100644 --- a/couchbase/transactions/transaction_options.hxx +++ b/couchbase/transactions/transaction_options.hxx @@ -76,40 +76,25 @@ class transaction_options [[nodiscard]] std::optional scan_consistency() const; /** - * Set the timeout for key-value operations for this transaction. + * Set the timeout for this transaction. * - * @param kv_timeout Desired key-value timeout. - * @return reference to this object, convenient for chaining operations. - */ - transaction_options& kv_timeout(std::chrono::milliseconds kv_timeout); - - /** - * Get the key-value timeout if it has been set. - * - * @return The key-value timeout, if set. - */ - std::optional kv_timeout(); - - /** - * Set the expiration time for this transaction. - * - * @tparam T expiration time type, e.g. @ref std::chrono::milliseconds, or similar - * @param expiration_time Desired expiration time. + * @tparam T timeout type, e.g. @ref std::chrono::milliseconds, or similar + * @param timeout Desired timeout * @return reference to this object, convenient for chaining operations. */ template - transaction_options& expiration_time(T expiration_time) + transaction_options& timeout(T timeout) { - expiration_time_ = std::chrono::duration_cast(expiration_time); + timeout_ = std::chrono::duration_cast(timeout); return *this; } /** - * Get the expiration time, if set. + * Get the timeout, if set. * - * @return the expiration time, if set. + * @return the timeout, if set. */ - std::optional expiration_time(); + std::optional timeout(); /** * Set the metadata collection to use for this transaction @@ -150,8 +135,7 @@ class transaction_options private: std::optional durability_; std::optional scan_consistency_; - std::optional kv_timeout_; - std::optional expiration_time_; + std::optional timeout_; std::optional metadata_collection_; std::shared_ptr attempt_context_hooks_; std::shared_ptr cleanup_hooks_; diff --git a/couchbase/transactions/transactions_config.hxx b/couchbase/transactions/transactions_config.hxx index 76852390d..c919c303d 100644 --- a/couchbase/transactions/transactions_config.hxx +++ b/couchbase/transactions/transactions_config.hxx @@ -79,55 +79,28 @@ class transactions_config } /** - * @brief Set kv_timeout - * - * @see kv_timeout() - * @param duration An std::chrono::duration representing the desired default kv operation timeout. - * @return reference to this, so calls can be chained. - */ - template - transactions_config& kv_timeout(T duration) - { - kv_timeout_ = std::chrono::duration_cast(duration); - return *this; - } - - /** - * @brief Get kv_timeout - * - * This is the default kv operation timeout used throughout the transactions. Note all the operations - * have an options class which allows you to override this value for a particular operation, if desired. - * - * @return The default kv operation timeout. - */ - [[nodiscard]] std::optional kv_timeout() const - { - return kv_timeout_; - } - - /** - * @brief Get expiration time for transactions + * @brief Get the timeout for transactions * * Transactions can conflict (or other operations on those documents), and may retry. * This is the maximum time a transaction can take, including any retries. The transaction will throw * an @ref transaction_expired and rollback when this occurs. * - * @return expiration time for transactions. + * @return timeout for transactions. */ - [[nodiscard]] std::chrono::nanoseconds expiration_time() const + [[nodiscard]] std::chrono::nanoseconds timeout() const { - return expiration_time_; + return timeout_; } /** - * @brief Set the expiration time for transactions. + * @brief Set the timeout for transactions. * * @param duration desired expiration for transactions. * @return reference to this, so calls can be chained. */ template - transactions_config& expiration_time(T duration) + transactions_config& timeout(T duration) { - expiration_time_ = std::chrono::duration_cast(duration); + timeout_ = std::chrono::duration_cast(duration); return *this; } @@ -236,8 +209,7 @@ class transactions_config /** @private */ struct built { couchbase::durability_level level; - std::chrono::nanoseconds expiration_time; - std::optional kv_timeout; + std::chrono::nanoseconds timeout; std::shared_ptr attempt_context_hooks; std::shared_ptr cleanup_hooks; std::optional metadata_collection; @@ -250,8 +222,7 @@ class transactions_config private: couchbase::durability_level level_{ couchbase::durability_level::majority }; - std::chrono::nanoseconds expiration_time_{ std::chrono::seconds(15) }; - std::optional kv_timeout_; + std::chrono::nanoseconds timeout_{ std::chrono::seconds(15) }; std::shared_ptr attempt_context_hooks_; std::shared_ptr cleanup_hooks_; std::optional metadata_collection_; diff --git a/docs/cbc-analytics.md b/docs/cbc-analytics.md index 25c6b6475..ad50ad8a1 100644 --- a/docs/cbc-analytics.md +++ b/docs/cbc-analytics.md @@ -103,8 +103,7 @@ Execute one or more Analytics queries and print results to standard output.
`--transactions-durability-level=LEVEL`
Durability level of the transaction (allowed values: `none`, `majority`, `majority_and_persist_to_active`, `persist_to_majority`). [default: `majority`]
-
`--transactions-expiration-time=DURATION`
Expiration time of the transaction. [default: `15000ms`]
-
`--transactions-key-value-timeout=DURATION`
Override Key/Value timeout just for the transaction.
+
`--transactions-timeout=DURATION`
Timeout of the transaction. [default: `15000ms`]
`--transactions-metadata-bucket=STRING`
Bucket name where transaction metadata is stored.
`--transactions-metadata-scope=STRING`
Scope name where transaction metadata is stored. [default: `_default`]
`--transactions-metadata-collection=STRING`
Collection name where transaction metadata is stored. [default: `_default`]
diff --git a/docs/cbc-get.md b/docs/cbc-get.md index efec0d600..530281c6e 100644 --- a/docs/cbc-get.md +++ b/docs/cbc-get.md @@ -103,8 +103,7 @@ Retrieve one or more documents from the server and print them to standard output
`--transactions-durability-level=LEVEL`
Durability level of the transaction (allowed values: `none`, `majority`, `majority_and_persist_to_active`, `persist_to_majority`). [default: `majority`]
-
`--transactions-expiration-time=DURATION`
Expiration time of the transaction. [default: `15000ms`]
-
`--transactions-key-value-timeout=DURATION`
Override Key/Value timeout just for the transaction.
+
`--transactions-timeout=DURATION`
Timeout of the transaction. [default: `15000ms`]
`--transactions-metadata-bucket=STRING`
Bucket name where transaction metadata is stored.
`--transactions-metadata-scope=STRING`
Scope name where transaction metadata is stored. [default: `_default`]
`--transactions-metadata-collection=STRING`
Collection name where transaction metadata is stored. [default: `_default`]
diff --git a/docs/cbc-pillowfight.md b/docs/cbc-pillowfight.md index 41a87afd9..50c0bea22 100644 --- a/docs/cbc-pillowfight.md +++ b/docs/cbc-pillowfight.md @@ -110,8 +110,7 @@ Run simple workload generator that sends GET/UPSERT requests with optional N1QL
`--transactions-durability-level=LEVEL`
Durability level of the transaction (allowed values: `none`, `majority`, `majority_and_persist_to_active`, `persist_to_majority`). [default: `majority`]
-
`--transactions-expiration-time=DURATION`
Expiration time of the transaction. [default: `15000ms`]
-
`--transactions-key-value-timeout=DURATION`
Override Key/Value timeout just for the transaction.
+
`--transactions-timeout=DURATION`
Timeout of the transaction. [default: `15000ms`]
`--transactions-metadata-bucket=STRING`
Bucket name where transaction metadata is stored.
`--transactions-metadata-scope=STRING`
Scope name where transaction metadata is stored. [default: `_default`]
`--transactions-metadata-collection=STRING`
Collection name where transaction metadata is stored. [default: `_default`]
diff --git a/docs/cbc-query.md b/docs/cbc-query.md index e0c54dcaf..73f4568af 100644 --- a/docs/cbc-query.md +++ b/docs/cbc-query.md @@ -111,8 +111,7 @@ Execute one or more N1QL queries and print results to standard output.
`--transactions-durability-level=LEVEL`
Durability level of the transaction (allowed values: `none`, `majority`, `majority_and_persist_to_active`, `persist_to_majority`). [default: `majority`]
-
`--transactions-expiration-time=DURATION`
Expiration time of the transaction. [default: `15000ms`]
-
`--transactions-key-value-timeout=DURATION`
Override Key/Value timeout just for the transaction.
+
`--transactions-timeout=DURATION`
Timeout of the transaction. [default: `15000ms`]
`--transactions-metadata-bucket=STRING`
Bucket name where transaction metadata is stored.
`--transactions-metadata-scope=STRING`
Scope name where transaction metadata is stored. [default: `_default`]
`--transactions-metadata-collection=STRING`
Collection name where transaction metadata is stored. [default: `_default`]
diff --git a/examples/bulk_transactional_api.cxx b/examples/bulk_transactional_api.cxx index c104cf279..fdb9da4d9 100644 --- a/examples/bulk_transactional_api.cxx +++ b/examples/bulk_transactional_api.cxx @@ -37,7 +37,7 @@ struct program_arguments { std::string collection_name{ couchbase::collection::default_name }; std::size_t number_of_operations{ 1'000 }; std::size_t document_body_size{ 1'024 }; - std::chrono::seconds transaction_expiration_time{ 120 }; + std::chrono::seconds transaction_timeout{ 120 }; static auto load_from_environment() -> program_arguments { @@ -74,11 +74,11 @@ struct program_arguments { arguments.document_body_size = int_val; } } - if (const auto* val = getenv("CB_TRANSACTION_EXPIRATION_TIME"); val != nullptr && val[0] != '\0') { + if (const auto* val = getenv("CB_TRANSACTION_TIMEOUT"); val != nullptr && val[0] != '\0') { char* end = nullptr; auto int_val = std::strtoul(val, &end, 10); if (end != val) { - arguments.transaction_expiration_time = std::chrono::seconds{ int_val }; + arguments.transaction_timeout = std::chrono::seconds{ int_val }; } } return arguments; @@ -193,8 +193,7 @@ run_workload_sequential(const std::shared_ptr& if (err.ec()) { fmt::print("\tTransaction completed with error {}, cause={}\n", err.ec().message(), err.cause().message()); if (err.ec() == couchbase::errc::transaction::expired) { - fmt::print("\tINFO: Try to increase CB_TRANSACTION_EXPIRATION_TIME, current value is {} seconds\n", - arguments.transaction_expiration_time); + fmt::print("\tINFO: Try to increase CB_TRANSACTION_TIMEOUT, current value is {} seconds\n", arguments.transaction_timeout); } } else { fmt::print("\tTransaction completed successfully\n"); @@ -419,15 +416,13 @@ run_workload_bulk(const std::shared_ptr& if (err.ec()) { fmt::print("\tTransaction completed with error {}, cause={}\n", err.ec().message(), err.cause().message()); if (err.ec() == couchbase::errc::transaction::expired) { - fmt::print("\tINFO: Try to increase CB_TRANSACTION_EXPIRATION_TIME, current value is {} seconds\n", - arguments.transaction_expiration_time); + fmt::print("\tINFO: Try to increase CB_TRANSACTION_TIMEOUT, current value is {} seconds\n", arguments.transaction_timeout); } } else { fmt::print("\tTransaction completed successfully\n"); } if (err.ec() == couchbase::errc::transaction::expired) { - fmt::print("\tINFO: Try to increase CB_TRANSACTION_EXPIRATION_TIME, current value is {} seconds\n", - arguments.transaction_expiration_time); + fmt::print("\tINFO: Try to increase CB_TRANSACTION_TIMEOUT, current value is {} seconds\n", arguments.transaction_timeout); } if (errors.empty()) { fmt::print("\tAll operations completed successfully\n"); @@ -459,7 +454,7 @@ main() fmt::print("CB_COLLECTION_NAME={}\n", arguments.collection_name); fmt::print("CB_NUMBER_OF_OPERATIONS={}\n", arguments.number_of_operations); fmt::print("CB_DOCUMENT_BODY_SIZE={}\n", arguments.document_body_size); - fmt::print("CB_TRANSACTION_EXPIRATION_TIME={}\n", arguments.transaction_expiration_time.count()); + fmt::print("CB_TRANSACTION_TIMEOUT={}\n", arguments.transaction_timeout.count()); asio::io_context io; auto guard = asio::make_work_guard(io); @@ -467,7 +462,7 @@ main() auto options = couchbase::cluster_options(arguments.username, arguments.password); options.apply_profile("wan_development"); - options.transactions().expiration_time(arguments.transaction_expiration_time); + options.transactions().timeout(arguments.transaction_timeout); auto [cluster, ec] = couchbase::cluster::connect(io, arguments.connection_string, options).get(); if (ec) { fmt::print("Unable to connect to cluster at \"{}\", error: {}\n", arguments.connection_string, ec.message()); diff --git a/examples/bulk_transactional_get_replace.cxx b/examples/bulk_transactional_get_replace.cxx index ed3969142..0b8654516 100644 --- a/examples/bulk_transactional_get_replace.cxx +++ b/examples/bulk_transactional_get_replace.cxx @@ -39,7 +39,7 @@ struct program_arguments { std::size_t number_of_transactions{ 5 }; std::size_t number_of_keys_per_transaction{ 10 }; std::size_t document_body_size{ 1'024 }; - std::chrono::seconds transaction_expiration_time{ 120 }; + std::chrono::seconds transaction_timeout{ 120 }; static auto load_from_environment() -> program_arguments { @@ -90,11 +90,11 @@ struct program_arguments { arguments.document_body_size = int_val; } } - if (const auto* val = getenv("CB_TRANSACTION_EXPIRATION_TIME"); val != nullptr && val[0] != '\0') { + if (const auto* val = getenv("CB_TRANSACTION_TIMEOUT"); val != nullptr && val[0] != '\0') { char* end = nullptr; auto int_val = std::strtoul(val, &end, 10); if (end != val) { - arguments.transaction_expiration_time = std::chrono::seconds{ int_val }; + arguments.transaction_timeout = std::chrono::seconds{ int_val }; } } return arguments; @@ -254,7 +254,7 @@ main() fmt::print("CB_NUMBER_OF_TRANSACTIONS={}\n", arguments.number_of_transactions); fmt::print("CB_NUMBER_OF_KEYS_PER_TRANSACTION={}\n", arguments.number_of_keys_per_transaction); fmt::print("CB_DOCUMENT_BODY_SIZE={}\n", arguments.document_body_size); - fmt::print("CB_TRANSACTION_EXPIRATION_TIME={}\n", arguments.transaction_expiration_time.count()); + fmt::print("CB_TRANSACTION_TIMEOUT={}\n", arguments.transaction_timeout.count()); asio::io_context io; auto guard = asio::make_work_guard(io); @@ -262,7 +262,7 @@ main() auto options = couchbase::cluster_options(arguments.username, arguments.password); options.apply_profile("wan_development"); - options.transactions().expiration_time(arguments.transaction_expiration_time); + options.transactions().timeout(arguments.transaction_timeout); auto [cluster, ec] = couchbase::cluster::connect(io, arguments.connection_string, options).get(); if (ec) { fmt::print("Unable to connect to cluster at \"{}\", error: {}\n", arguments.connection_string, ec.message()); diff --git a/examples/game_server.cxx b/examples/game_server.cxx index 7e85d2622..cac83cda9 100644 --- a/examples/game_server.cxx +++ b/examples/game_server.cxx @@ -223,7 +223,7 @@ main() options.transactions().durability_level(couchbase::durability_level::majority); options.transactions().cleanup_config().cleanup_lost_attempts(true); options.transactions().cleanup_config().cleanup_client_attempts(true); - options.transactions().expiration_time(std::chrono::milliseconds(100)); + options.transactions().timeout(std::chrono::milliseconds(100)); auto [cluster, ec] = couchbase::cluster::connect(io, "couchbase://localhost", options).get(); if (ec) { diff --git a/test/test_transaction_context.cxx b/test/test_transaction_context.cxx index a19f937de..a58c712fc 100644 --- a/test/test_transaction_context.cxx +++ b/test/test_transaction_context.cxx @@ -70,8 +70,8 @@ TEST_CASE("transactions: can do simple transaction with transaction wrapper", "[ test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -110,8 +110,8 @@ TEST_CASE("transactions: can do simple transaction with finalize", "[transaction test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -158,8 +158,8 @@ TEST_CASE("transactions: can do simple transaction explicit commit", "[transacti test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -204,8 +204,8 @@ TEST_CASE("transactions: can do rollback simple transaction", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -247,8 +247,8 @@ TEST_CASE("transactions: can get insert errors", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -287,8 +287,8 @@ TEST_CASE("transactions: can get remove errors", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -329,8 +329,8 @@ TEST_CASE("transactions: can get replace errors", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -375,8 +375,8 @@ TEST_CASE("transactions: RYOW get after insert", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -408,8 +408,8 @@ TEST_CASE("transactions: can get get errors", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -437,8 +437,8 @@ TEST_CASE("transactions: can do query", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -474,8 +474,8 @@ TEST_CASE("transactions: can see some query errors but no transactions failed", test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); test::utils::open_bucket(integration.cluster, integration.ctx.bucket); couchbase::core::document_id id{ integration.ctx.bucket, "_default", "_default", test::utils::uniq_id("txn") }; @@ -515,20 +515,18 @@ TEST_CASE("transactions: can set per transaction config", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); auto barrier = std::make_shared>(); auto f = barrier->get_future(); couchbase::transactions::transaction_options per_txn_cfg; per_txn_cfg.scan_consistency(couchbase::query_scan_consistency::not_bounded) - .expiration_time(std::chrono::milliseconds(1)) - .kv_timeout(std::chrono::milliseconds(2)) + .timeout(std::chrono::milliseconds(1)) .durability_level(couchbase::durability_level::none); transaction_context tx(txns, per_txn_cfg); REQUIRE(tx.config().level == per_txn_cfg.durability_level()); - REQUIRE(tx.config().kv_timeout == per_txn_cfg.kv_timeout()); - REQUIRE(tx.config().expiration_time == per_txn_cfg.expiration_time()); + REQUIRE(tx.config().timeout == per_txn_cfg.timeout()); REQUIRE(tx.config().query_config.scan_consistency == per_txn_cfg.scan_consistency()); } @@ -537,14 +535,13 @@ TEST_CASE("transactions: can not per transactions config", "[transactions]") test::utils::integration_test_guard integration; auto cluster = integration.cluster; - couchbase::core::transactions::transactions txns( - cluster, couchbase::transactions::transactions_config().expiration_time(std::chrono::seconds(2))); + couchbase::core::transactions::transactions txns(cluster, + couchbase::transactions::transactions_config().timeout(std::chrono::seconds(2))); auto barrier = std::make_shared>(); auto f = barrier->get_future(); transaction_context tx(txns); REQUIRE(tx.config().level == txns.config().level); - REQUIRE(tx.config().kv_timeout == txns.config().kv_timeout); - REQUIRE(tx.config().expiration_time == txns.config().expiration_time); + REQUIRE(tx.config().timeout == txns.config().timeout); REQUIRE(tx.config().query_config.scan_consistency == txns.config().query_config.scan_consistency); } diff --git a/test/test_transaction_public_async_api.cxx b/test/test_transaction_public_async_api.cxx index aa418fcd1..4fe332675 100644 --- a/test/test_transaction_public_async_api.cxx +++ b/test/test_transaction_public_async_api.cxx @@ -28,7 +28,7 @@ couchbase::transactions::transaction_options async_options() { couchbase::transactions::transaction_options cfg; - cfg.expiration_time(std::chrono::seconds(1)); + cfg.timeout(std::chrono::seconds(1)); return cfg; } @@ -305,7 +305,7 @@ TEST_CASE("transactions public async API: can set transaction options", "[transa REQUIRE_SUCCESS(err.ec()); auto begin = std::chrono::steady_clock::now(); - auto cfg = couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(2)); + auto cfg = couchbase::transactions::transaction_options().timeout(std::chrono::seconds(2)); auto barrier = std::make_shared>(); auto f = barrier->get_future(); c.transactions()->run( @@ -320,10 +320,10 @@ TEST_CASE("transactions public async API: can set transaction options", "[transa [&begin, &cfg, barrier](auto e, auto res) { auto end = std::chrono::steady_clock::now(); auto elapsed = std::chrono::duration_cast(end - begin); - // should be greater than the expiration time - CHECK(elapsed > *cfg.expiration_time()); + // should be greater than the timeout + CHECK(elapsed > *cfg.timeout()); // but not by too much (default is 15 seconds, we wanted 1, 2 is plenty) - CHECK(elapsed < (2 * *cfg.expiration_time())); + CHECK(elapsed < (2 * *cfg.timeout())); // and of course the txn should have expired CHECK_FALSE(res.transaction_id.empty()); CHECK_FALSE(res.unstaging_complete); diff --git a/test/test_transaction_public_blocking_api.cxx b/test/test_transaction_public_blocking_api.cxx index 013f0e8fb..32787e41d 100644 --- a/test/test_transaction_public_blocking_api.cxx +++ b/test/test_transaction_public_blocking_api.cxx @@ -34,7 +34,7 @@ couchbase::transactions::transaction_options txn_opts() { couchbase::transactions::transaction_options opts{}; - opts.expiration_time(std::chrono::seconds(2)); + opts.timeout(std::chrono::seconds(2)); return opts; } void @@ -366,7 +366,7 @@ TEST_CASE("transactions public blocking API: can pass per-transaction configs", auto [err, upsert_res] = coll.upsert(id, content, {}).get(); REQUIRE_SUCCESS(err.ec()); - auto opts = couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(2)); + auto opts = couchbase::transactions::transaction_options().timeout(std::chrono::seconds(2)); auto begin = std::chrono::steady_clock::now(); auto [tx_err, result] = c.transactions()->run( [id, coll](couchbase::transactions::attempt_context& ctx) { @@ -380,10 +380,10 @@ TEST_CASE("transactions public blocking API: can pass per-transaction configs", opts); auto end = std::chrono::steady_clock::now(); auto elapsed = std::chrono::duration_cast(end - begin); - // should be greater than the expiration time - CHECK(elapsed > *opts.expiration_time()); + // should be greater than the timeout + CHECK(elapsed > *opts.timeout()); // but not by too much (default is 15 seconds, we wanted 2, 2x that is plenty) - CHECK(elapsed < (2 * *opts.expiration_time())); + CHECK(elapsed < (2 * *opts.timeout())); CHECK_FALSE(result.transaction_id.empty()); CHECK_FALSE(result.unstaging_complete); // could have failed in rollback, which returns fail rather than expired @@ -405,7 +405,7 @@ TEST_CASE("transactions public blocking API: can do simple query", "[transaction CHECK_FALSE(e.ec()); CHECK(content == res.rows_as_json().front()["default"]); }, - couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(10))); + couchbase::transactions::transaction_options().timeout(std::chrono::seconds(10))); CHECK_FALSE(tx_err.ec()); CHECK(result.unstaging_complete); CHECK_FALSE(result.transaction_id.empty()); @@ -426,7 +426,7 @@ TEST_CASE("transactions public blocking API: can do simple mutating query", "[tr auto [e, res] = ctx.query(fmt::format("UPDATE `{}` USE KEYS '{}' SET `some_number` = 10", test_ctx.bucket, id)); CHECK_FALSE(e.ec()); }, - couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(10))); + couchbase::transactions::transaction_options().timeout(std::chrono::seconds(10))); CHECK_FALSE(tx_err.ec()); CHECK(result.unstaging_complete); CHECK_FALSE(result.transaction_id.empty()); @@ -451,7 +451,7 @@ TEST_CASE("transactions public blocking API: some query errors don't force rollb ctx.query(fmt::format(R"(INSERT INTO `{}` (KEY, VALUE) VALUES ("{}", {}))", test_ctx.bucket, id, content_json)); CHECK_FALSE(insert_err.ec()); }, - couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(10))); + couchbase::transactions::transaction_options().timeout(std::chrono::seconds(10))); CHECK_FALSE(tx_err.ec()); CHECK(result.unstaging_complete); CHECK_FALSE(result.transaction_id.empty()); @@ -479,7 +479,7 @@ TEST_CASE("transactions public blocking API: some query errors do rollback", "[t auto [e2, __] = ctx.query(fmt::format(R"(INSERT INTO `{}` (KEY, VALUE) VALUES ("{}", {}))", test_ctx.bucket, id, content_json)); CHECK_FALSE(e2.ec()); }, - couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(10))); + couchbase::transactions::transaction_options().timeout(std::chrono::seconds(10))); CHECK(tx_err.ec() == couchbase::errc::transaction::failed); // id2 should not exist, since the txn should have rolled back. @@ -501,7 +501,7 @@ TEST_CASE("transactions public blocking API: some query errors are seen immediat CHECK(e.ec()); CHECK(std::holds_alternative(e.cause())); }, - couchbase::transactions::transaction_options().expiration_time(std::chrono::seconds(10))); + couchbase::transactions::transaction_options().timeout(std::chrono::seconds(10))); CHECK_FALSE(tx_err.ec()); CHECK_FALSE(result.transaction_id.empty()); CHECK(result.unstaging_complete); diff --git a/test/test_transaction_simple.cxx b/test/test_transaction_simple.cxx index 68e0ef687..830427379 100644 --- a/test/test_transaction_simple.cxx +++ b/test/test_transaction_simple.cxx @@ -45,7 +45,7 @@ couchbase::transactions::transactions_config get_conf() { couchbase::transactions::transactions_config cfg{}; - cfg.expiration_time(std::chrono::seconds(2)); + cfg.timeout(std::chrono::seconds(2)); return cfg; } @@ -228,7 +228,7 @@ TEST_CASE("transactions: non existent scope in custom metadata collections", "[t "i_dont_exist", couchbase::collection::default_name, }); - cfg.expiration_time(std::chrono::seconds(2)); + cfg.timeout(std::chrono::seconds(2)); transactions txn(cluster, cfg); // upsert initial doc @@ -266,7 +266,7 @@ TEST_CASE("transactions: non existent collection in custom metadata collections" get_conf() .metadata_collection(couchbase::transactions::transaction_keyspace{ "secBucket", couchbase::scope::default_name, "i_dont_exist" }) .cleanup_config(couchbase::transactions::transactions_cleanup_config().cleanup_lost_attempts(true)); - cfg.expiration_time(std::chrono::seconds(2)); + cfg.timeout(std::chrono::seconds(2)); transactions txn(cluster, cfg); // upsert initial doc diff --git a/test/test_transaction_simple_async.cxx b/test/test_transaction_simple_async.cxx index a256e9851..86e0222bb 100644 --- a/test/test_transaction_simple_async.cxx +++ b/test/test_transaction_simple_async.cxx @@ -34,7 +34,7 @@ couchbase::transactions::transactions_config get_conf() { couchbase::transactions::transactions_config cfg{}; - cfg.expiration_time(std::chrono::seconds(1)); + cfg.timeout(std::chrono::seconds(1)); return cfg; } diff --git a/tools/utils.cxx b/tools/utils.cxx index 783a11c7f..1273b1f5f 100644 --- a/tools/utils.cxx +++ b/tools/utils.cxx @@ -217,10 +217,8 @@ add_options(CLI::App* app, transactions_options& options) group->add_option("--transactions-durability-level", options.durability_level, "Durability level of the transaction.") ->default_val(fmt::format("{}", defaults.transactions.level)) ->transform(CLI::IsMember(available_durability_levels)); - group->add_option("--transactions-expiration-time", options.expiration_time, "Expiration time of the transaction.") - ->default_val(defaults.transactions.expiration_time) - ->type_name("DURATION"); - group->add_option("--transactions-key-value-timeout", options.key_value_timeout, "Override Key/Value timeout just for the transaction.") + group->add_option("--transactions-timeout", options.timeout, "Timeout of the transaction.") + ->default_val(defaults.transactions.timeout) ->type_name("DURATION"); group->add_option("--transactions-metadata-bucket", options.metadata_bucket, "Bucket name where transaction metadata is stored."); group->add_option("--transactions-metadata-scope", options.metadata_scope, "Scope name where transaction metadata is stored.") @@ -424,10 +422,7 @@ apply_options(couchbase::cluster_options& options, const transactions_options& t } else if (!transactions.durability_level.empty()) { fail(fmt::format("unexpected value '{}' for --transactions-durability-level", transactions.durability_level)); } - options.transactions().expiration_time(transactions.expiration_time); - if (transactions.key_value_timeout > std::chrono::milliseconds::zero()) { - options.transactions().kv_timeout(transactions.key_value_timeout); - } + options.transactions().timeout(transactions.timeout); if (!transactions.metadata_bucket.empty()) { options.transactions().metadata_collection( { transactions.metadata_bucket, transactions.metadata_scope, transactions.metadata_collection }); diff --git a/tools/utils.hxx b/tools/utils.hxx index 0f1351560..7a856cd15 100644 --- a/tools/utils.hxx +++ b/tools/utils.hxx @@ -129,8 +129,7 @@ struct network_options { struct transactions_options { std::string durability_level{}; - std::chrono::milliseconds expiration_time{}; - std::chrono::milliseconds key_value_timeout{}; + std::chrono::milliseconds timeout{}; std::string metadata_bucket{}; std::string metadata_scope{}; std::string metadata_collection{};