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 →
- Write
expiresAtas a Number with$(date -d '+1 day' +%s), not milliseconds - 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.
More on RDS, Aurora and DynamoDB
The app cannot connect to RDS: `psql: error: connection to server at "mydb.abc.us-east-1.rds.amazonaws.com" (10.0.3.12), port 5432 failed: Connection timed out`.Beginner`FATAL: password authentication failed for user "postgres"` and nobody knows the master password.Beginner`FATAL: no pg_hba.conf entry for host "10.0.1.25", user "app", database "orders", no encryption`.IntermediateApp logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).IntermediateRDS status shows `storage-full` and writes fail.IntermediateA read replica's `ReplicaLag` keeps growing and reports show stale data.Intermediate