Interview Prep/AWS/RDS, Aurora and DynamoDB

TTL is enabled, but expired items are still in the table days later.

IntermediateTroubleshootingRDS, Aurora and DynamoDB
Answer

Likely causes → The TTL attribute is not a Number in epoch seconds (a string or milliseconds is ignored), the attribute name does not match, or deletion is simply lagging. TTL deletes in the background, usually within a few days.

Diagnose →

aws dynamodb describe-time-to-live --table-name sessions
aws dynamodb get-item --table-name sessions --key '{"id":{"S":"s-1"}}' --query 'Item.expiresAt'
date +%s

Fix →

  1. Write expiresAt as a Number with $(date -d '+1 day' +%s), not milliseconds
  2. Filter out expired items in reads (expiresAt > :now) until they are deleted

Prevent → Use a unit test for TTL values, and use the TimeToLiveDeletedItemCount metric to confirm deletes are happening.

aws All AWS questions Roadmap: AWS core services

More on RDS, Aurora and DynamoDB