Skip to content

fix: Retry throttled DynamoDB writes without blocking evaluations - #532

Draft
keelerm84 wants to merge 2 commits into
mainfrom
mk/SDK-3814/dynamodb-unprocessed-items
Draft

keelerm84 wants to merge 2 commits into
mainfrom
mk/SDK-3814/dynamodb-unprocessed-items

Conversation

@keelerm84

@keelerm84 keelerm84 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

SDK-3814. Found while reviewing the work for #504; it matters more once postfork children stop doing a full init.

Describe the solution you've provided

DynamoDBUtil.batch_write_requests called batch_write_item and ignored the response's unprocessed_items. When DynamoDB throttled part of a batch, those writes were lost without an error, and init could write the $inited marker and report success while the table held partial data.

Each batch is now retried until DynamoDB accepts every item:

  • Only the items DynamoDB returned as unprocessed are resent.
  • A batch rejected with ProvisionedThroughputExceededException is retried too, sharing the same budget. Other errors are raised as before.
  • Retries use jittered exponential backoff: 10 retries, 100 ms base, 5 s cap. These are the values the js-core DynamoDB store uses.
  • A batch finishes retrying before the next one starts, so the caller's order holds (prerequisites before dependents, $inited last).
  • If items remain unprocessed after the last retry, it raises, so init and the store status report the failure.

Retrying makes a write slow, so the second commit keeps it from blocking evaluations. Store held @lock, which every evaluation takes to find the active store, for the whole of each persistent write in apply and commit. Both now update or snapshot the memory store under @lock and write to the persistent store after releasing it. A new @write_lock, taken only by writers, serializes apply and commit, so changesets and their writes keep their order. A slow write now delays later changesets, not evaluations.

The new specs use the AWS SDK's stubbed client, so they run without DynamoDB. They fail without the fix.

Describe alternatives you've considered

Go (go-server-sdk-dynamodb batchWriteRequests) and Java (DynamoDbDataStoreImpl) also ignore UnprocessedItems, so they are not a usable reference here. js-core's DynamoDBClientState.batchWrite is the one SDK that handles it, and this follows its behaviour.

Additional context

I did not run the DynamoDB integration specs against a local DynamoDB for this change; the stubbed-client specs cover the retry logic. python-server-sdk has the same bug, which is tracked separately.

…g them

DynamoDBUtil.batch_write_requests ignored the unprocessed_items in each
BatchWriteItem response, so throttled writes were lost without an error and
init could report success with partial data. Retry unprocessed items, and
batches rejected with ProvisionedThroughputExceededException, with jittered
exponential backoff, one batch at a time so the write order is kept. Raise
if items remain unprocessed after the retries. The retry budget matches the
js-core DynamoDB store.

SDK-3814
Store held @lock, which every evaluation takes to find the active store,
for the whole of each persistent write in apply and commit. A slow write,
such as DynamoDB retrying throttled items, blocked every evaluation for
as long as it ran.

Apply and commit now update or snapshot the memory store under @lock and
write to the persistent store after releasing it. A new @write_lock,
taken only by writers, serializes apply and commit, so changesets and
their persistent writes keep their order and commit's snapshot cannot
interleave with a changeset.

SDK-3814
@keelerm84 keelerm84 changed the title fix: Retry DynamoDB writes that DynamoDB throttles instead of dropping them fix: Retry throttled DynamoDB writes without blocking evaluations Dec 4, 2026

This branch has not been deployed

No deployments
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.

1 participant