Does Apache Phoenix automatically invalidate its client-side query result cache when an HBase region split occurs?
0 reputation · 22 May 2023, 18:49 UTC
0 reputation · 22 May 2023, 18:49 UTC
The goal is to determine whether Apache Phoenix's optional client-side query result cache is automatically invalidated when an HBase region undergoes a split or compaction, so that application developers can decide if manual cache flushing is required to maintain repeatable reads.
The cache is keyed by the SQL statement and bound parameters, but Phoenix does not register listeners for HBase region server events such as splits, flushes or compactions. Consequently, cached result sets can become stale and remain usable until they are evicted by LRU limits, expire after the configured TTL, or are explicitly flushed via the PhoenixConnection API. The community has not converged on a default invalidation policy, leaving users to weigh the performance benefit of caching against the risk of serving outdated data.
Does Phoenix provide any built-in hook to detect region split events and purge matching cache entries?
When automatic invalidation is unavailable, what configuration or application-level practices best balance cache hit rates with consistency requirements?
34775 reputation · 22 May 2023, 21:16 UTC
No, Apache Phoenix does not automatically invalidate its optional client-side query result cache when an HBase region split, flush, or compaction occurs. There is no built-in hook or event listener that triggers a cache purge based on HBase region server topology changes.
The client-side query result cache is keyed by the SQL statement and its bound parameters. Because the Phoenix client does not register as a listener for HBase region events, it remains unaware of backend structural changes. While a region split does not inherently change the data's visibility within HBase, the cached result set on the client remains static. This means the client will continue to serve the cached data until one of the following occurs:
PhoenixConnection API.To balance performance (cache hit rates) with data freshness (consistency), developers should implement the following practices based on their requirements:
| Requirement | Recommended Approach | Trade-off |
|---|---|---|
| Strong Consistency | Disable client-side caching or use a very short TTL. | Increased latency and HBase load. |
| Eventual Consistency | Set a moderate TTL (e.g., minutes) and rely on LRU eviction. | Risk of stale reads during the TTL window. |
| Write-Through Freshness | Manually trigger a cache flush via the API following a significant write operation. | Increased application complexity. |
To verify if your current configuration is susceptible to stale reads during region splits, you can perform the following test in a staging environment:
split 'table_name', 'split_row_key'.Diagnostic Note: To provide a more specific recommendation on TTL values, please specify if your workload is read-heavy with rare updates or involves frequent concurrent writes to the same row keys.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.