diff --git a/bindings/go/src/fdb/generated.go b/bindings/go/src/fdb/generated.go index 77599d407b..2a7c40f6aa 100644 --- a/bindings/go/src/fdb/generated.go +++ b/bindings/go/src/fdb/generated.go @@ -412,7 +412,7 @@ func (o TransactionOptions) SetMaxRetryDelay(param int64) error { // Set the maximum transaction size which, if exceeded, will cause the transaction to be cancelled. Valid parameter values are ``[32, 10,000,000]```. // // Parameter: value in bytes -func (o TransactionOptions) SetMaxTransactionSize(param int64) error { +func (o TransactionOptions) SetSizeLimit(param int64) error { return o.setOpt(503, int64ToBytes(param)) } diff --git a/documentation/sphinx/source/api-common.rst.inc b/documentation/sphinx/source/api-common.rst.inc index d188864b8e..2a436a99db 100644 --- a/documentation/sphinx/source/api-common.rst.inc +++ b/documentation/sphinx/source/api-common.rst.inc @@ -308,7 +308,7 @@ .. |option-db-tr-size-limit-blurb| replace:: - Set the default maximum transaction size in bytes. This is equivalent to calling |transaction-size-limit-database-option| on each transaction created by this database. + Set the default maximum transaction size in bytes. This is equivalent to calling |transaction-size-limit-database-option| on each transaction created by this database. This limit can be overridden by setting per transaction size limit, which persists across transaction reset. .. |option-db-tr-timeout-blurb| replace:: @@ -397,6 +397,10 @@ Set the maximum backoff delay incurred in the call to |on-error-func| if the error is retryable. Prior to API version 610, like all other transaction options, the maximum retry delay must be reset after a call to |on-error-func|. If the API version is 610 or newer, then the maximum retry delay is not reset. Note that at all API versions, it is safe and legal to call this option after each call to |on-error-func|, so most cade written assuming the older behavior can be upgraded without requiring any modification. This also means there is no need to introduce logic to conditionally set this option within retry loops. One can set the default retry limit for all transactions by calling |max-retry-delay-database-option|. +.. |option-set-size-limit-blurb| replace:: + + Set the maximum transaction size limit in bytes. This size limit will persists transaction reset. + .. |option-set-timeout-blurb1| replace:: Set a timeout duration in milliseconds after which the transaction automatically to be cancelled. The time is measured from transaction creation (or the most call to |reset-func-name|, if any). Valid parameter values are [0, INT_MAX]. If set to 0, all timeouts will be disabled. Once a transaction has timed out, all pending or future uses of the transaction will |error-raise-type| a :ref:`transaction_timed_out ` |error-type|. The transaction can be used again after it is |reset-func-name|. diff --git a/documentation/sphinx/source/api-python.rst b/documentation/sphinx/source/api-python.rst index 7b1be0efba..81d7e21252 100644 --- a/documentation/sphinx/source/api-python.rst +++ b/documentation/sphinx/source/api-python.rst @@ -32,7 +32,7 @@ .. |retry-limit-transaction-option| replace:: :func:`Transaction.options.set_retry_limit` .. |timeout-transaction-option| replace:: :func:`Transaction.options.set_timeout` .. |max-retry-delay-transaction-option| replace:: :func:`Transaction.options.set_max_retry_delay` -.. |size-limit-transaction-option| replace:: :func:`Transaction.options.set_transaction_size_limit` +.. |size-limit-transaction-option| replace:: :func:`Transaction.options.set_size_limit` .. |snapshot-ryw-enable-transaction-option| replace:: :func:`Transaction.options.set_snapshot_ryw_enable` .. |snapshot-ryw-disable-transaction-option| replace:: :func:`Transaction.options.set_snapshot_ryw_disable` .. |lazy-iterator-object| replace:: generator @@ -841,6 +841,10 @@ Transaction options |option-set-max-retry-delay-blurb| +.. method:: Transaction.options.set_size_limit + + |option-set-size-limit-blurb| + .. _api-python-timeout: .. method:: Transaction.options.set_timeout diff --git a/documentation/sphinx/source/api-ruby.rst b/documentation/sphinx/source/api-ruby.rst index 442275107e..c0539cb5cd 100644 --- a/documentation/sphinx/source/api-ruby.rst +++ b/documentation/sphinx/source/api-ruby.rst @@ -30,7 +30,7 @@ .. |retry-limit-transaction-option| replace:: :meth:`Transaction.options.set_retry_limit` .. |timeout-transaction-option| replace:: :meth:`Transaction.options.set_timeout` .. |max-retry-delay-transaction-option| replace:: :meth:`Transaction.options.set_max_retry_delay` -.. |size-limit-transaction-option| replace:: :meth:`Transaction.options.set_transaction_size_limit` +.. |size-limit-transaction-option| replace:: :meth:`Transaction.options.set_size_limit` .. |snapshot-ryw-enable-transaction-option| replace:: :meth:`Transaction.options.set_snapshot_ryw_enable` .. |snapshot-ryw-disable-transaction-option| replace:: :meth:`Transaction.options.set_snapshot_ryw_disable` .. |lazy-iterator-object| replace:: :class:`Enumerator` @@ -785,6 +785,10 @@ Transaction options |option-set-max-retry-delay-blurb| +.. method:: Transaction.options.set_size_limit() -> nil + + |option-set-size-limit-blurb| + .. method:: Transaction.options.set_timeout() -> nil |option-set-timeout-blurb1| diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp index a0e6a29a69..af3fc25e89 100644 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -584,7 +584,7 @@ namespace dbBackup { loop{ try { tr.setOption(FDBTransactionOptions::LOCK_AWARE); - tr.options.customTransactionSizeLimit = 2 * CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; + tr.options.sizeLimit = 2 * CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; wait(checkDatabaseLock(&tr, BinaryReader::fromStringRef(task->params[BackupAgentBase::keyConfigLogUid], Unversioned()))); state int64_t bytesSet = 0; @@ -1080,7 +1080,7 @@ namespace dbBackup { loop{ try { tr.setOption(FDBTransactionOptions::LOCK_AWARE); - tr.options.customTransactionSizeLimit = 2 * CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; + tr.options.sizeLimit = 2 * CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; wait(checkDatabaseLock(&tr, BinaryReader::fromStringRef(task->params[BackupAgentBase::keyConfigLogUid], Unversioned()))); state int64_t bytesSet = 0; diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index f5f0ab0e94..eca185e8f8 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -157,7 +157,7 @@ public: double transactionTimeout; int transactionMaxRetries; double transactionMaxBackoff; - int transactionMaxBytes; + int transactionMaxSize; // Max size in bytes. int snapshotRywEnabled; Future logger; diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 12b65eaa43..5ed4c55b95 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -524,7 +524,7 @@ DatabaseContext::DatabaseContext( maxOutstandingWatches = CLIENT_KNOBS->DEFAULT_MAX_OUTSTANDING_WATCHES; transactionMaxBackoff = CLIENT_KNOBS->FAILURE_MAX_DELAY; - transactionMaxBytes = CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; + transactionMaxSize = CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; snapshotRywEnabled = apiVersionAtLeast(300) ? 1 : 0; logger = databaseLogger( this ); @@ -750,7 +750,7 @@ void DatabaseContext::setOption( FDBDatabaseOptions::Option option, OptionalTRANSACTION_SIZE_LIMIT); + transactionMaxSize = extractIntOption(value, 32, CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT); break; case FDBDatabaseOptions::SNAPSHOT_RYW_ENABLE: validateOptionValue(value, false); @@ -2403,7 +2403,7 @@ double Transaction::getBackoff(int errCode) { TransactionOptions::TransactionOptions(Database const& cx) { maxBackoff = cx->transactionMaxBackoff; - customTransactionSizeLimit = cx->transactionMaxBytes; + sizeLimit = cx->transactionMaxSize; reset(cx); if (BUGGIFY) { commitOnFirstProxy = true; @@ -2417,16 +2417,16 @@ TransactionOptions::TransactionOptions(Database const& cx) { TransactionOptions::TransactionOptions() { memset(this, 0, sizeof(*this)); maxBackoff = CLIENT_KNOBS->DEFAULT_MAX_BACKOFF; - customTransactionSizeLimit = CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; + sizeLimit = CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT; } void TransactionOptions::reset(Database const& cx) { double oldMaxBackoff = maxBackoff; double oldMaxRetries = maxRetries; - uint32_t oldSizeLimit = customTransactionSizeLimit; + uint32_t oldSizeLimit = sizeLimit; memset(this, 0, sizeof(*this)); maxBackoff = cx->apiVersionAtLeast(610) ? oldMaxBackoff : cx->transactionMaxBackoff; - customTransactionSizeLimit = oldSizeLimit; + sizeLimit = oldSizeLimit; maxRetries = oldMaxRetries; lockAware = cx->lockAware; } @@ -2762,7 +2762,7 @@ Future Transaction::commitMutations() { transactionSize = tr.transaction.mutations.expectedSize(); // Old API versions didn't account for conflict ranges when determining whether to throw transaction_too_large } - if (transactionSize > options.customTransactionSizeLimit) { + if (transactionSize > options.sizeLimit) { return transaction_too_large(); } @@ -2937,6 +2937,11 @@ void Transaction::setOption( FDBTransactionOptions::Option option, Optional::max()) / 1000.0; break; + case FDBTransactionOptions::SIZE_LIMIT: + validateOptionValue(value, true); + options.sizeLimit = extractIntOption(value, 32, CLIENT_KNOBS->TRANSACTION_SIZE_LIMIT); + break; + case FDBTransactionOptions::LOCK_AWARE: validateOptionValue(value, false); options.lockAware = true; diff --git a/fdbclient/NativeAPI.actor.h b/fdbclient/NativeAPI.actor.h index 3c8f9dc5b7..bb089914f2 100644 --- a/fdbclient/NativeAPI.actor.h +++ b/fdbclient/NativeAPI.actor.h @@ -143,7 +143,7 @@ struct TransactionOptions { double maxBackoff; uint32_t maxRetries; uint32_t getReadVersionFlags; - uint32_t customTransactionSizeLimit; + uint32_t sizeLimit; bool checkWritesEnabled : 1; bool causalWriteRisky : 1; bool commitOnFirstProxy : 1; diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index eab1b81755..61b8de669e 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -146,8 +146,8 @@ description is not currently required but encouraged. paramType="Int" paramDescription="value in milliseconds of maximum delay" description="Set the maximum amount of backoff delay incurred in the call to ``onError`` if the error is retryable. This sets the ``max_retry_delay`` option of each transaction created by this database. See the transaction option description for more information." />