Limits of Automatic Cache Invalidation in HDFS After File Modifications
0 reputation · 01 Aug 2020, 11:50 UTC
0 reputation · 01 Aug 2020, 11:50 UTC
When a file stored in HDFS is truncated, overwritten, or replaced, the DataNode block replicas that have been loaded into the off‑heap cache via hdfs cacheadmin remain unchanged unless the cached path is explicitly removed or uncached.
Consequently, read requests that hit the cached block may return stale data, and the cache does not self‑heal even though the underlying file has been modified. Documentation states that cache coherence is the responsibility of the application or administrator, and no automatic invalidation mechanism is currently implemented in either the 2.x or 3.x release lines.
Given this behavior, what options exist for applications that require up‑to‑date reads without incurring the operational overhead of manual cache management? Are there any configuration flags or auxiliary services that can trigger cache invalidation on file modification events? Is there a roadmap for introducing automatic cache coherence in future HDFS versions?
35275 reputation · 01 Aug 2020, 20:19 UTC
When a file in HDFS is truncated, overwritten, or replaced, DataNode block replicas loaded into the off-heap cache via hdfs cacheadmin remain unchanged. The cache does not self-heal; it is unaware of underlying file system-level changes, leading to stale data reads for any request hitting the cached blocks.
HDFS design philosophy places cache coherence responsibility on the application layer or the administrator. There is currently no native automatic invalidation mechanism in either the 2.x or 3.x release lines that monitors file modification events to flush or update the off-heap cache.
Since HDFS does not provide automatic coherence, applications must implement one of the following strategies to ensure data freshness:
hdfs cacheadmin -remove [path] immediately after any write, truncate, or replace operation.There are no configuration flags in hdfs-site.xml that enable automatic cache invalidation upon file modification. To avoid manual overhead, developers often use auxiliary microservices that listen to HDFS EditLog changes and orchestrate the cacheadmin commands based on detected file update events.
As of the current development cycle, there is no official roadmap for introducing automatic cache coherence in future HDFS versions. The off-heap cache is primarily intended for static or frequently-read-heavy datasets where data changes infrequently. For workloads requiring high consistency with frequent updates, the recommendation is to bypass the HDFS cache entirely or use an external distributed caching layer.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.