Repository navigation
HBASE-30362 Migrate IndexOnlyLRU to cache admission policy - #8876
VladRodionov wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
The override callssuper.shouldAdmit(...)but discards its returnedAdmissionDecision, then… · New The rejection reason is misleading whenblockType == null(it’s not being rejected because it’s a… · New The class exposes a singletonINSTANCEbut does not prevent additional instantiation. To enforce… · New
What changed in this PR
Migrates the legacy IndexOnlyLRU behavior to the pluggable cache architecture by expressing “index-only” behavior as a cache admission policy while using the native LruCacheEngine.
Changes:
- Add
IndexOnlyCachePlacementAdmissionPolicyand select it whenhbase.blockcache.policy=IndexOnlyLRU. - Switch
IndexOnlyLRUto useLruCacheEngine(instead of wrappingIndexOnlyLruBlockCache) while preserving “reject DATA, admit non-DATA” semantics. - Update/add unit tests to validate the new engine/policy wiring and preserved admission behavior.
| File | Description |
|---|---|
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/IndexOnlyCachePlacementAdmissionPolicy.java | Introduces admission policy intended to replicate legacy IndexOnlyLRU admission behavior. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServices.java | Wires IndexOnlyLRU policy name to the new admission policy. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheFactory.java | Routes IndexOnlyLRU to use LruCacheEngine directly. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestIndexOnlyCachePlacementAdmissionPolicy.java | Adds focused unit tests for the new admission policy. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java | Updates cache config test to assert engine/policy wiring and admission behavior. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientSideRegionScanner.java | Updates client-side scanner test to assert engine/tier/policy under IndexOnlyLRU. |
Review effort: Lite
| return blockType != null && blockType.getCategory() != BlockType.BlockCategory.DATA | ||
| ? AdmissionDecision.admit() | ||
| : AdmissionDecision.reject("IndexOnlyLRU admits only non-data blocks"); |
There was a problem hiding this comment.
this one is right, please check and add tests for it.
There was a problem hiding this comment.
Is it possible at all for blockType being null?
|
|
||
| public static final IndexOnlyCachePlacementAdmissionPolicy INSTANCE = | ||
| new IndexOnlyCachePlacementAdmissionPolicy(); | ||
|
|
| return blockType != null && blockType.getCategory() != BlockType.BlockCategory.DATA | ||
| ? AdmissionDecision.admit() | ||
| : AdmissionDecision.reject("IndexOnlyLRU admits only non-data blocks"); |
There was a problem hiding this comment.
this one is right, please check and add tests for it.
|
|
||
| if (policy.equalsIgnoreCase("LRU")) { | ||
| if ( | ||
| policy.equalsIgnoreCase("LRU") || policy.equalsIgnoreCase("AdaptiveLRU") |
There was a problem hiding this comment.
for all these type of policy, we should start using ENUM for it.
Thanks @VladRodionov. The single-tier path looks equivalent to the legacy 1. Tiered topologies no longer cache data blocks in L2
Could we mirror 2. Discarded Agree with @taklwu that this is harmless today, since the parent only null-checks and admits. It would silently ignore a rejection if the default policy ever starts returning one, though. Suggest capturing the decision and returning early when it is not admitted, as the Adaptive policy does. 3. Allocation per rejected data block
4. Leftovers
Note: this review is from reading the code; I did not build or run the tests locally. |
|
on 2. DefaultHBaseCachePlacementAdmissionPolicy always admits by definition. |
|
It turned out that fixing |



Summary
Migrate
IndexOnlyLRUto the pluggable cache architecture.The legacy
IndexOnlyLruBlockCachespecializesLruBlockCacheonly by filtering cacheadmission: data blocks are rejected while non-data blocks are admitted. Rather than introducing
another specialized
CacheEngine, this change represents that behavior using the existing cachearchitecture:
LruCacheEnginefor cache storage and LRU evictionSingleTierTopologyfor the standalone cache topologyIndexOnlyCachePlacementAdmissionPolicyfor block admissionThis keeps admission policy separate from cache-engine implementation.
Changes
IndexOnlyCachePlacementAdmissionPolicy.IndexOnlyLruBlockCacheadmission semantics:DATAcategoryhbase.blockcache.policy=IndexOnlyLRU.LruCacheEnginefor theIndexOnlyLRUconfiguration.TestCacheConfigto verify the new engine/policy architecture and preserved admissionbehavior.
TestClientSideRegionScannerto verify that its cache uses:LruCacheEngineCacheTier.SINGLEIndexOnlyCachePlacementAdmissionPolicyIndexOnlyCachePlacementAdmissionPolicy.Architecture
Before:
After:
The legacy
IndexOnlyLruBlockCacheremains available for the transitionalBlockCachepath andcan be removed together with the remaining
BlockCacheimplementation during the final migration.Behavior
No user-visible behavior change is intended.
Despite its historical name,
IndexOnlyLruBlockCacheadmits all non-data blocks rather than onlyliteral index blocks. The new admission policy intentionally preserves that behavior.
AI-assisted development
This change was developed in collaboration with ChatGPT 5.6 Sol. ChatGPT was used as a
development and review assistant for architecture discussion, code migration, and test adaptation.
All resulting code and design decisions were reviewed and validated by the author.