Error: dynamodb atomic counter not working

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
A DynamoDB counter should be updated in one UpdateItem request. Reading a value, incrementing it locally and writing it back loses updates when callers run concurrently.
- Use
ADD #count :one, with:oneas a Number. A missing counter starts at zero. - Alias the attribute name, for example
{ "#count": "count" }, because expression names can be reserved. - Supply the full primary key and request
ReturnValues: "UPDATED_NEW"to receive the updated counter. - Do not mix native document-client values with low-level DynamoDB JSON descriptors.
An increment is atomic but not idempotent: a retry after an ambiguous timeout can increment twice. Use idempotency records or conditional transactions when a business event must count exactly once.
The SDK v3 counter example shows a complete request. See also AWS item operations.
Other Common DynamoDB Errors (with Solutions)
- a bytes-like object is required not binary dynamodb
- dynamodb global secondary index does not project
- 'dynamodb' object has no attribute 'table'
- name key is not defined dynamodb
- DynamoDB Mapper Could Not Instantiate Class
- dynamodb item size limit error
- DynamoDB BatchWriteItem error
- DynamoDB missing items
- ProvisionedThroughputExceededException DynamoDB
- dynamodb localhost not working
- dynamodb the table does not have the specified index
- dynamodb put item not working
- DynamoDB Duplicate Key Error
- DynamoDB is missing the key id in the item
- DynamoDB attribute not empty
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase