Skip to content

ReturnConsumedCapacity Support for DynamoDB Transactions in DynamoDBContext and Table APIs#4412

Draft
aanton-git wants to merge 9 commits into
aws:developmentfrom
aanton-git:feature/ReturnConsumedCapacity-transactional-operations
Draft

ReturnConsumedCapacity Support for DynamoDB Transactions in DynamoDBContext and Table APIs#4412
aanton-git wants to merge 9 commits into
aws:developmentfrom
aanton-git:feature/ReturnConsumedCapacity-transactional-operations

Conversation

@aanton-git
Copy link
Copy Markdown
Contributor

Description

Add ReturnConsumedCapacity support for DynamoDB transactional operations exposed through DynamoDBContext and Table-level APIs in the AWS SDK for .NET.

Currently, when executing transactions via high-level .NET abstractions (such as DynamoDBContext transactional APIs or Table-based helpers), there is no way to request or retrieve consumed capacity information. This capability is supported by DynamoDB itself and exposed in other SDKs, but is missing from the .NET high-level APIs.

Motivation and Context

I need this feature to understand and control the capacity cost of transactional workloads when using DynamoDB through DynamoDBContext.

Without ReturnConsumedCapacity:

  • Transactional RCUs/WCUs are opaque at the request level
  • Capacity usage cannot be attributed per transaction or per table
  • Cost analysis and performance tuning for transactions is significantly harder than for non-transactional operations

Expose ReturnConsumedCapacity at the DynamoDBContext and Table abstraction level for transactional operations, in a way consistent with existing .NET SDK patterns.

Specifically:

Allow configuring ReturnConsumedCapacity when executing transactional reads and writes through DynamoDBContext
Surface consumed-capacity data in the transaction response
Include total and per-table capacity information, consistent with other DynamoDB APIs
This should not require customers to drop down to low-level TransactWriteItemsRequest / TransactGetItemsRequest APIs.
The AWS SDK for Java v2 Enhanced Client already supports this feature, providing a clear reference for API shape and behavior.
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequest.Builder.html

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

/// </summary>
/// <param name="hashKey">Hash key of the item to get.</param>
void AddKey(object hashKey);
/// <param name="returnConsumedCapacity">Constants used for properties of type ReturnConsumedCapacity</param>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update summary with actual scope, but move it to TransactGetConfig

}

/// <inheritdoc/>
public void AddKeys(IEnumerable<T> keyObjects)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not default to null ReturnConsumedCapacity

{
var transactItems = Items.Select(item => item.GetRequest()).ToList();
var request = new TransactWriteItemsRequest { TransactItems = transactItems };
var returnConsumedCapacity =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ReturnConsumedCapacity should be part of the TransactWriteConfig and set only one time when CreateTransactWrite, not added for each item

/// <param name="item">Item to save.</param>
void AddSaveItem(T item);
/// <param name="returnConsumedCapacity">Constants used for properties of type ReturnConsumedCapacity.</param>
void AddSaveItem(T item, ReturnConsumedCapacity returnConsumedCapacity = null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move ReturnConsumedCapacity to config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants