Address review comments for PR#1725

This commit is contained in:
Jingyu Zhou 2019-06-20 14:06:32 -07:00
parent ebc7e7cb4a
commit 3a63d053e9
9 changed files with 37 additions and 20 deletions

View File

@ -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))
}

View File

@ -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 <developer-guide-error-codes>` |error-type|. The transaction can be used again after it is |reset-func-name|.

View File

@ -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

View File

@ -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|

View File

@ -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<UID>(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<UID>(task->params[BackupAgentBase::keyConfigLogUid], Unversioned())));
state int64_t bytesSet = 0;

View File

@ -157,7 +157,7 @@ public:
double transactionTimeout;
int transactionMaxRetries;
double transactionMaxBackoff;
int transactionMaxBytes;
int transactionMaxSize; // Max size in bytes.
int snapshotRywEnabled;
Future<Void> logger;

View File

@ -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, Optional<Str
break;
case FDBDatabaseOptions::TRANSACTION_SIZE_LIMIT:
validateOptionValue(value, true);
transactionMaxBytes = extractIntOption(value, 32, CLIENT_KNOBS->TRANSACTION_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<Void> 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<Stri
options.maxBackoff = extractIntOption(value, 0, std::numeric_limits<int32_t>::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;

View File

@ -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;

View File

@ -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." />
<Option name="transaction_size_limit" code="503"
paramType="Int" paramDescription="value in bytes"
description="Set the maximum transaction size which, if exceeded, will cause the transaction to be cancelled. Default to 10,000,000 bytes." />
paramType="Int" paramDescription="value in bytes"
description="Set the maximum transaction size which, if exceeded, will cause the transaction to be cancelled. Default to 10,000,000 bytes." />
<Option name="snapshot_ryw_enable" code="26"
description="Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior." />
<Option name="snapshot_ryw_disable" code="27"
@ -203,9 +203,9 @@ description is not currently required but encouraged.
<Option name="max_retry_delay" code="502"
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. Defaults to 1000 ms. Valid parameter values are ``[0, INT_MAX]``. If the maximum retry delay is less than the current retry delay of the transaction, then the current retry delay will be clamped to the maximum retry delay. Prior to API version 610, like all other transaction options, the maximum retry delay must be reset after a call to ``onError``. If the API version is 610 or greater, the retry limit is not reset after an ``onError`` call. Note that at all API versions, it is safe and legal to set the maximum retry delay each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option."/>
<Option name="max_transaction_size" code="503"
paramType="Int" paramDescription="value in bytes"
description="Set the maximum transaction size which, if exceeded, will cause the transaction to be cancelled. Valid parameter values are ``[32, 10,000,000]```." />
<Option name="size_limit" code="503"
paramType="Int" paramDescription="value in bytes"
description="Set the maximum transaction size which, if exceeded, will cause the transaction to be cancelled. Valid parameter values are ``[32, 10,000,000]```." />
<Option name="snapshot_ryw_enable" code="600"
description="Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior." />
<Option name="snapshot_ryw_disable" code="601"