DynamoDB / Client / exceptions / TransactionCanceledException

TransactionCanceledException#

class DynamoDB.Client.exceptions.TransactionCanceledException#

The entire transaction request was canceled.

DynamoDB cancels a TransactWriteItems request under the following circumstances:

  • A condition in one of the condition expressions is not met.

  • A table in the TransactWriteItems request is in a different account or region.

  • More than one action in the TransactWriteItems operation targets the same item.

  • There is insufficient provisioned capacity for the transaction to be completed.

  • An item size becomes too large (larger than 400 KB), or a local secondary index (LSI) becomes too large, or a similar validation error occurs because of changes made by the transaction.

  • There is a user error, such as an invalid data format.

  • There is an ongoing TransactWriteItems operation that conflicts with a concurrent TransactWriteItems request. In this case the TransactWriteItems operation fails with a TransactionCanceledException.

DynamoDB cancels a TransactGetItems request under the following circumstances:

  • There is an ongoing TransactGetItems operation that conflicts with a concurrent PutItem, UpdateItem, DeleteItem or TransactWriteItems request. In this case the TransactGetItems operation fails with a TransactionCanceledException.

  • A table in the TransactGetItems request is in a different account or region.

  • There is insufficient provisioned capacity for the transaction to be completed.

  • There is a user error, such as an invalid data format.

Note

If using Java, DynamoDB lists the cancellation reasons on the CancellationReasons property. This property is not set for other languages. Transaction cancellation reasons are ordered in the order of requested items, if an item has no error it will have None code and Null message.

Cancellation reason codes and possible error messages:

  • No Errors:

    • Code: None

    • Message: null

  • Conditional Check Failed:

    • Code: ConditionalCheckFailed

    • Message: The conditional request failed.

  • Item Collection Size Limit Exceeded:

    • Code: ItemCollectionSizeLimitExceeded

    • Message: Collection size exceeded.

  • Transaction Conflict:

    • Code: TransactionConflict

    • Message: Transaction is ongoing for the item.

  • Provisioned Throughput Exceeded:

    • Code: ProvisionedThroughputExceeded

    • Messages:

      • The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API.

      Note

      This Message is received when provisioned throughput is exceeded is on a provisioned DynamoDB table.

      • The level of configured provisioned throughput for one or more global secondary indexes of the table was exceeded. Consider increasing your provisioning level for the under-provisioned global secondary indexes with the UpdateTable API.

      Note

      This message is returned when provisioned throughput is exceeded is on a provisioned GSI.

  • Throttling Error:

    • Code: ThrottlingError

    • Messages:

      Note

      This message is returned when writes get throttled on an On-Demand table as DynamoDB is automatically scaling the table.

      • Throughput exceeds the current capacity for one or more global secondary indexes. DynamoDB is automatically scaling your index so please try again shortly.

      Note

      This message is returned when writes get throttled on an On-Demand GSI as DynamoDB is automatically scaling the GSI.

  • Validation Error:

    • Code: ValidationError

    • Messages:

      • One or more parameter values were invalid.

      • The update expression attempted to update the secondary index key beyond allowed size limits.

      • The update expression attempted to update the secondary index key to unsupported type.

      • An operand in the update expression has an incorrect data type.

      • Item size to update has exceeded the maximum allowed size.

      • Number overflow. Attempting to store a number with magnitude larger than supported range.

      • Type mismatch for attribute to update.

      • Nesting Levels have exceeded supported limits.

      • The document path provided in the update expression is invalid for update.

      • The provided expression refers to an attribute that does not exist in the item.

Example

try:
  ...
except client.exceptions.TransactionCanceledException as e:
  print(e.response)
response#

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'CancellationReasons': [
        {
            'Item': {
                'string': {
                    'S': 'string',
                    'N': 'string',
                    'B': b'bytes',
                    'SS': [
                        'string',
                    ],
                    'NS': [
                        'string',
                    ],
                    'BS': [
                        b'bytes',
                    ],
                    'M': {
                        'string': {'... recursive ...'}
                    },
                    'L': [
                        {'... recursive ...'},
                    ],
                    'NULL': True|False,
                    'BOOL': True|False
                }
            },
            'Code': 'string',
            'Message': 'string'
        },
    ],
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) –

    The entire transaction request was canceled.

    DynamoDB cancels a TransactWriteItems request under the following circumstances:

    • A condition in one of the condition expressions is not met.

    • A table in the TransactWriteItems request is in a different account or region.

    • More than one action in the TransactWriteItems operation targets the same item.

    • There is insufficient provisioned capacity for the transaction to be completed.

    • An item size becomes too large (larger than 400 KB), or a local secondary index (LSI) becomes too large, or a similar validation error occurs because of changes made by the transaction.

    • There is a user error, such as an invalid data format.

    • There is an ongoing TransactWriteItems operation that conflicts with a concurrent TransactWriteItems request. In this case the TransactWriteItems operation fails with a TransactionCanceledException.

    DynamoDB cancels a TransactGetItems request under the following circumstances:

    • There is an ongoing TransactGetItems operation that conflicts with a concurrent PutItem, UpdateItem, DeleteItem or TransactWriteItems request. In this case the TransactGetItems operation fails with a TransactionCanceledException.

    • A table in the TransactGetItems request is in a different account or region.

    • There is insufficient provisioned capacity for the transaction to be completed.

    • There is a user error, such as an invalid data format.

    Note

    If using Java, DynamoDB lists the cancellation reasons on the CancellationReasons property. This property is not set for other languages. Transaction cancellation reasons are ordered in the order of requested items, if an item has no error it will have None code and Null message.

    Cancellation reason codes and possible error messages:

    • No Errors:

      • Code: None

      • Message: null

    • Conditional Check Failed:

      • Code: ConditionalCheckFailed

      • Message: The conditional request failed.

    • Item Collection Size Limit Exceeded:

      • Code: ItemCollectionSizeLimitExceeded

      • Message: Collection size exceeded.

    • Transaction Conflict:

      • Code: TransactionConflict

      • Message: Transaction is ongoing for the item.

    • Provisioned Throughput Exceeded:

      • Code: ProvisionedThroughputExceeded

      • Messages:

        • The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API.

        Note

        This Message is received when provisioned throughput is exceeded is on a provisioned DynamoDB table.

        • The level of configured provisioned throughput for one or more global secondary indexes of the table was exceeded. Consider increasing your provisioning level for the under-provisioned global secondary indexes with the UpdateTable API.

        Note

        This message is returned when provisioned throughput is exceeded is on a provisioned GSI.

    • Throttling Error:

      • Code: ThrottlingError

      • Messages:

        Note

        This message is returned when writes get throttled on an On-Demand table as DynamoDB is automatically scaling the table.

        • Throughput exceeds the current capacity for one or more global secondary indexes. DynamoDB is automatically scaling your index so please try again shortly.

        Note

        This message is returned when writes get throttled on an On-Demand GSI as DynamoDB is automatically scaling the GSI.

    • Validation Error:

      • Code: ValidationError

      • Messages:

        • One or more parameter values were invalid.

        • The update expression attempted to update the secondary index key beyond allowed size limits.

        • The update expression attempted to update the secondary index key to unsupported type.

        • An operand in the update expression has an incorrect data type.

        • Item size to update has exceeded the maximum allowed size.

        • Number overflow. Attempting to store a number with magnitude larger than supported range.

        • Type mismatch for attribute to update.

        • Nesting Levels have exceeded supported limits.

        • The document path provided in the update expression is invalid for update.

        • The provided expression refers to an attribute that does not exist in the item.

    • Message (string) –

    • CancellationReasons (list) –

      A list of cancellation reasons.

      • (dict) –

        An ordered list of errors for each item in the request which caused the transaction to get cancelled. The values of the list are ordered according to the ordering of the TransactWriteItems request parameter. If no error occurred for the associated item an error with a Null code and Null message will be present.

        • Item (dict) –

          Item in the request which caused the transaction to get cancelled.

          • (string) –

            • (dict) –

              Represents the data for an attribute.

              Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.

              For more information, see Data Types in the Amazon DynamoDB Developer Guide.

              • S (string) –

                An attribute of type String. For example:

                "S": "Hello"

              • N (string) –

                An attribute of type Number. For example:

                "N": "123.45"

                Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

              • B (bytes) –

                An attribute of type Binary. For example:

                "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"

              • SS (list) –

                An attribute of type String Set. For example:

                "SS": ["Giraffe", "Hippo" ,"Zebra"]

                • (string) –

              • NS (list) –

                An attribute of type Number Set. For example:

                "NS": ["42.2", "-19", "7.5", "3.14"]

                Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations.

                • (string) –

              • BS (list) –

                An attribute of type Binary Set. For example:

                "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]

                • (bytes) –

              • M (dict) –

                An attribute of type Map. For example:

                "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}

                • (string) –

                  • (dict) –

                    Represents the data for an attribute.

                    Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.

                    For more information, see Data Types in the Amazon DynamoDB Developer Guide.

              • L (list) –

                An attribute of type List. For example:

                "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N": "3.14159"}]

                • (dict) –

                  Represents the data for an attribute.

                  Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.

                  For more information, see Data Types in the Amazon DynamoDB Developer Guide.

              • NULL (boolean) –

                An attribute of type Null. For example:

                "NULL": true

              • BOOL (boolean) –

                An attribute of type Boolean. For example:

                "BOOL": true

        • Code (string) –

          Status code for the result of the cancelled transaction.

        • Message (string) –

          Cancellation reason message description.

    • Error (dict) – Normalized access to common exception attributes.

      • Code (string) – An identifier specifying the exception type.

      • Message (string) – A descriptive message explaining why the exception occured.