dynobase-icon
Dynobase

Error: dynamodb atomic counter not working

Rafal Wilinski

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 :one as 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.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.