bito-code-review[bot] commented on PR #44662:
URL: https://github.com/apache/superset/pull/44662#issuecomment-5963978646
<!-- Bito Reply -->
The flagged issue is correct. The PR introduces `skip_oversized_cache_value`
to address this race condition. This function ensures that if a value is too
large to be cached, it is not written to the cache, and any existing smaller
value under the same key is explicitly deleted. This prevents the cache from
serving stale, smaller data when a newer, larger result was just computed but
skipped due to size constraints.
The implementation is correct and robustly handles the race condition by
ensuring the cache key is cleared if the write is skipped. No further changes
are needed for this specific issue.
**superset/utils/cache.py**
```
def skip_oversized_cache_value(
cache_instance: Cache, cache_key: str, value: Any
) -> bool:
if not exceeds_max_cache_value_size(cache_key, value):
return False
if not isinstance(cache_instance.cache, NullCache):
try:
cache_instance.delete(cache_key)
except Exception: # pylint: disable=broad-except
logger.warning(
"Could not delete cache key %s after skipping an oversized
value",
cache_key,
exc_info=True,
)
return True
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]