Fix async-execution cache keys leaking with no TTL#7631
Merged
Conversation
`cache_task_tracking_key()` used `cache.set()` which stores
`id-{request_id}-async-execution` keys with no expiry. These keys
accumulate indefinitely — one per privacy request and request task
queued. On a customer instance this resulted in 3.7M leaked keys
inflating the Redis keyspace and increasing the cost of every
SCAN/KEYS operation.
Switch to `cache.set_with_autoexpire()` so these keys expire with
the default 7-day TTL, matching the behavior of other cache keys.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Contributor
Greptile SummaryThis PR fixes a Redis key leak where
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 206a589 |
Ensures a future refactor can't silently reintroduce the no-TTL regression by verifying that cache_task_tracking_key stores keys with a positive TTL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
thabofletcher
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket [ENG-N/A]
Description Of Changes
cache_task_tracking_key()usedcache.set()to storeid-{request_id}-async-executionkeys with no TTL, causing them to accumulate indefinitely — one per privacy request and request task queued. On a customer instance this resulted in 3.7M leaked keys, inflating the Redis keyspace and increasing the cost of everySCAN/KEYSoperation.Switched to
cache.set_with_autoexpire()so these keys expire with the default 7-day TTL, matching the behavior of other cache keys (e.g. identity keys, encoded objects).Code Changes
cache.set()tocache.set_with_autoexpire()incache_task_tracking_key()(src/fides/api/util/cache.py)Steps to Confirm
redis-cli TTL id-{request_id}-async-execution— should return ~604800 (7 days)get_cached_task_id)Pre-Merge Checklist
CHANGELOG.mdupdated