Bird
Raised Fist0
DynamoDBquery~20 mins

Unprocessed items handling in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Unprocessed Items Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
What is the output when BatchWriteItem returns unprocessed items?

You send a BatchWriteItem request to DynamoDB with 5 items. The response contains 2 unprocessed items. What does this mean?

AAll 5 items were written successfully.
B2 items were not written and need to be retried.
CThe request failed and no items were written.
DOnly 3 items were sent to DynamoDB.
Attempts:
2 left
💡 Hint

Unprocessed items are those DynamoDB could not write due to capacity limits.

🧠 Conceptual
intermediate
2:00remaining
Why does DynamoDB return unprocessed items in BatchWriteItem?

Which of the following is the main reason DynamoDB returns unprocessed items in a BatchWriteItem response?

ABecause DynamoDB exceeded provisioned throughput limits.
BBecause the request syntax was invalid.
CBecause the items were duplicates.
DBecause the table does not exist.
Attempts:
2 left
💡 Hint

Think about capacity and limits on writes per second.

📝 Syntax
advanced
3:00remaining
Which code snippet correctly retries unprocessed items in BatchWriteItem?

Given a BatchWriteItem response with unprocessed items, which code snippet correctly retries them until all are processed?

A
while response['UnprocessedItems'] is None:
    response = client.batch_write_item(RequestItems=response['UnprocessedItems'])
B
if response['UnprocessedItems']:
    client.batch_write_item(RequestItems=response['UnprocessedItems'])
C
for item in response['UnprocessedItems']:
    client.batch_write_item(RequestItems=item)
D
while 'UnprocessedItems' in response and response['UnprocessedItems']:
    response = client.batch_write_item(RequestItems=response['UnprocessedItems'])
Attempts:
2 left
💡 Hint

Retry while unprocessed items exist.

❓ optimization
advanced
3:00remaining
How to optimize handling of unprocessed items in BatchWriteItem?

Which approach best optimizes handling unprocessed items returned by BatchWriteItem to avoid throttling?

AUse exponential backoff with jitter when retrying unprocessed items.
BImmediately retry all unprocessed items in a tight loop without delay.
CIgnore unprocessed items and proceed without retrying.
DSplit unprocessed items into single-item requests and retry sequentially.
Attempts:
2 left
💡 Hint

Think about how to reduce load and avoid repeated throttling.

🔧 Debug
expert
3:00remaining
Why does this retry code cause infinite loop on unprocessed items?

Consider this Python code snippet retrying unprocessed items from BatchWriteItem:

while response['UnprocessedItems']:
    response = client.batch_write_item(RequestItems=response['UnprocessedItems'])

Why might this cause an infinite loop?

DynamoDB
while response['UnprocessedItems']:
    response = client.batch_write_item(RequestItems=response['UnprocessedItems'])
ABecause the loop condition should check for None, not empty dict.
BBecause 'UnprocessedItems' key is missing from response, causing KeyError.
CBecause it retries immediately without delay, causing repeated throttling and unprocessed items never clear.
DBecause batch_write_item does not accept 'RequestItems' parameter.
Attempts:
2 left
💡 Hint

Think about what happens if you retry too fast.

Practice

(1/5)
1. What does DynamoDB return when some items in a batch write are not processed immediately?
easy
A. An error stopping the entire batch operation
B. A partial success with no retry information
C. A success message without details
D. A list of unprocessed items to retry later

Solution

  1. Step 1: Understand batch write behavior

    DynamoDB may not process all items in a batch due to throttling or limits.
  2. Step 2: Identify returned data for unprocessed items

    It returns unprocessed items so the client can retry sending them.
  3. Final Answer:

    A list of unprocessed items to retry later -> Option D
  4. Quick Check:

    Unprocessed items = retry list [OK]
Hint: Unprocessed items mean retry those items later [OK]
Common Mistakes:
  • Thinking DynamoDB throws an error instead
  • Assuming all items are processed without feedback
  • Ignoring unprocessed items in code
2. Which of the following is the correct way to check for unprocessed items in a DynamoDB BatchWriteItem response in Python?
easy
A. if 'UnprocessedItems' in response and response['UnprocessedItems']:
B. if response['UnprocessedItems'] == None:
C. if response['UnprocessedItems'] is False:
D. if 'UnprocessedItems' not in response:

Solution

  1. Step 1: Understand response structure

    The response includes 'UnprocessedItems' key if any items were not processed.
  2. Step 2: Correctly check for unprocessed items

    Check if 'UnprocessedItems' exists and is not empty to retry those items.
  3. Final Answer:

    if 'UnprocessedItems' in response and response['UnprocessedItems']: -> Option A
  4. Quick Check:

    Check key exists and is not empty [OK]
Hint: Check key exists and is not empty to find unprocessed items [OK]
Common Mistakes:
  • Checking for None instead of empty dict
  • Using 'not in' which misses unprocessed items
  • Checking for False which is incorrect
3. Given this Python snippet handling DynamoDB batch write:
response = client.batch_write_item(RequestItems=batch)
if response.get('UnprocessedItems'):
    retry_items = response['UnprocessedItems']
else:
    retry_items = None
print(retry_items)
What will be printed if all items were processed successfully?
medium
A. List of all items
B. {}
C. None
D. An error

Solution

  1. Step 1: Understand response when all items processed

    If all items are processed, 'UnprocessedItems' key is empty or missing.
  2. Step 2: Analyze code behavior

    response.get('UnprocessedItems') returns None or empty dict; if empty dict is falsy, else branch sets retry_items to None.
  3. Final Answer:

    None -> Option C
  4. Quick Check:

    No unprocessed items means retry_items = None [OK]
Hint: If no unprocessed items, retry_items is None [OK]
Common Mistakes:
  • Expecting empty dict instead of None
  • Assuming an error is raised
  • Thinking retry_items contains all items
4. You wrote this code to resend unprocessed items but it never stops retrying:
while True:
    response = client.batch_write_item(RequestItems=items)
    items = response.get('UnprocessedItems', {})
    if not items:
        break
What is the likely bug causing infinite retries?
medium
A. Missing a delay between retries causing throttling
B. Using 'break' inside the loop incorrectly
C. Not updating 'items' with the new unprocessed items correctly
D. Not checking for empty dictionary properly

Solution

  1. Step 1: Analyze the retry loop

    The code updates items correctly but retries immediately without delay.
  2. Step 2: Identify the cause of infinite retries

    Missing delay or exponential backoff leads to rapid retries, causing persistent throttling. DynamoDB continually returns the same unprocessed items.
  3. Final Answer:

    Missing a delay between retries causing throttling -> Option A
  4. Quick Check:

    Add sleep/backoff between retries [OK]
Hint: Add delay or backoff between batch retries to avoid throttling [OK]
Common Mistakes:
  • Blaming item update logic instead of throttling
  • Assuming empty dict check prevents infinite loops
  • Overlooking need for backoff in tight retry loops
5. You want to ensure all items in a large batch are saved in DynamoDB without loss. Which approach best handles unprocessed items efficiently?
hard
A. Split items into single writes to avoid unprocessed items
B. Check for unprocessed items after each batch write and retry them until none remain
C. Send all items once and ignore unprocessed items since they are rare
D. Use batch write once and log unprocessed items without retrying

Solution

  1. Step 1: Understand batch write limitations

    DynamoDB batch writes can return unprocessed items due to throttling or limits.
  2. Step 2: Best practice for data safety

    Retry unprocessed items repeatedly until all are saved to avoid data loss.
  3. Final Answer:

    Check for unprocessed items after each batch write and retry them until none remain -> Option B
  4. Quick Check:

    Retry unprocessed items until empty for safe writes [OK]
Hint: Always retry unprocessed items until all are saved [OK]
Common Mistakes:
  • Ignoring unprocessed items causing data loss
  • Writing items one by one causing inefficiency
  • Logging without retrying unprocessed items
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard