Repository navigation
HBASE-30471 Remove LruBlockCache dependencies from test and production code - #8844
Conversation
|
Ran PR through GPT Astra. No actionable findings in PR #8844 at commit 897814a. |
There was a problem hiding this comment.
🟡 Changes recommended
The test inspects a cache the region never uses, so its zero-count assertions pass even if scanner selection reads excluded files.
1 open issue
What changed in this PR
This PR continues HBase’s pluggable block cache migration by replacing direct LruBlockCache dependencies with LruCacheEngine and cache-service abstractions, while retaining legacy compatibility adapters. No user-visible behavior change is intended.
Changes:
- Moves LRU-specific coverage into
TestLruCacheEngine. - Migrates HFile tests and cache inspection to
CacheAccessService. - Extends test helpers and updates production API documentation and compatibility handling.
| File | Description |
|---|---|
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java |
Clears cached blocks through the service API. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java |
Uses service-based cached-file inspection. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java |
Removes the migrated legacy test suite. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLazyDataBlockDecompression.java |
Tests compression with native LRU engines. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileScannerImplReferenceCount.java |
Migrates LRU scanner coverage to the service API. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileDataBlockEncoder.java |
Uses a service-backed LRU test instance. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBlockIndex.java |
Creates caches through service test helpers. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCombinedBlockCache.java |
Uses the extracted concurrency test helper. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheOnWrite.java |
Uses service-based configuration and cache clearing. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/CacheTestUtils.java |
Adds engine overloads for shared assertions. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestLruCacheEngine.java |
Receives migrated LRU behavior coverage. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestCacheAccessServiceTestFactory.java |
Verifies native LRU factory instances. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestInstance.java |
Supports native engines and legacy caches. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestFactory.java |
Creates native LRU services and single-tier wrappers. |
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/BlockCacheTestUtils.java |
Extracts concurrent cache-operation helpers. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruCachedBlock.java |
Updates the documented owning cache implementation. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java |
Generalizes heap-allocation comments. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java |
Generalizes heap-allocation parameter documentation. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/TopologyBackedCacheAccessServices.java |
Returns null when no legacy cache backs an engine. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/TopologyBackedCacheAccessService.java |
Updates cache-size documentation to reference native LRU. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/LruCacheEngine.java |
Exposes configuration and eviction-thread access for tests. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngine.java |
Documents native engines and compatibility adapters. |
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessService.java |
Updates documentation to reference LruCacheEngine. |
Review effort: Balanced
|
|
||
| Scan scan = new Scan().withStartRow(Bytes.toBytes("aaa")).withStopRow(Bytes.toBytes("aaz")); | ||
| BlockCache cache = BlockCacheFactory.createBlockCache(conf); | ||
| CacheAccessService cache = CacheAccessServices.fromConfiguration(conf); |
897814a to
c6d4b7f
Compare
anmolnar
left a comment
There was a problem hiding this comment.
AI-assisted review — drafted by Claude (Anthropic) on behalf of @anmolnar
Thanks for the migration, this is in good shape overall. I went through all 23 files. Two things I verified up front:
- All 13 tests from the deleted
TestLruBlockCacheare present inTestLruCacheEnginewith identical bodies (only the class name changes, and the multi-thread helper moved toBlockCacheTestUtils). - The Copilot finding on
TestScannerSelectionUsingKeyRangelooks addressed inc6d4b7f: theCacheAccessServiceis now created before the region and passed tocreateRegionAndWAL, and the file-count assertion is no longer guarded byinstanceof LruBlockCache. That thread can be resolved.
A few questions and requests before I approve:
1. TopologyBackedCacheAccessServices.getBlockCache now returns null
The IllegalArgumentException for a non-BlockCacheBackedCacheEngine was replaced with return null, but the only two callers touched by this patch (both in TestCacheOnWrite) were removed. Which caller needs the new behaviour? It also makes the method inconsistent: a missing tier still throws, while a native engine returns null. Could we either keep the exception, or return Optional<BlockCache> and update the Javadoc?
2. CacheAccessServiceTestInstance.blockCache() contract change
It used to return the concrete T and now returns BlockCache, which is null for native engines. Since every lruInstance(...) now produces an LruCacheEngine, any remaining test on the branch that calls lruInstance(...).blockCache() would get null at runtime instead of a compile error. Could you confirm there are no such callers left? Dropping the T extends BlockCache bound in favour of a runtime instanceof check also loses some compile-time safety; two small factory methods (one per kind) might be cleaner.
3. EncodedSeekPerformanceTest: Lists import
This imports org.apache.hadoop.util.Lists, which is a Hadoop-internal class. Please use org.apache.hbase.thirdparty.com.google.common.collect.Lists (as TestCacheOnWrite does) or new ArrayList<>(...).
4. TestCacheOnWrite: possibly unused import
Both usages of TopologyBackedCacheAccessServices visible in the diff were removed, but the import remains. If nothing else in the file uses it, checkstyle will complain.
5. Widened visibility in LruCacheEngine
getEvictionThread() and LRU_HARD_CAPACITY_LIMIT_FACTOR_CONFIG_NAME are now public so tests in io.hfile can reach them. Fine for the constant; for getEvictionThread() could we add @RestrictedApi limited to test paths?
Nits (non-blocking)
CacheAccessServiceTestFactory.singleTierServicehas no Javadoc, is unused in this patch, and duplicates the privatecreateCacheAccessServiceinCacheAccessServiceTestInstance.CacheEngineJavadoc: the edit drops a</p>, leaving a paragraph unclosed.TestHFileScannerImplReferenceCount.testDisabledBlockCache: the comment "Must be a single-tier LruCacheEngine" sits next to anullcache.CacheTestUtils.getBlockAndAssertEquals(CacheEngine, ...):actualBlockis dereferenced before the null check infinally; anassertNotNullfirst would give a clearer failure.BlockCacheTestUtils: the two overloads are identical bodies; a shared private helper would remove the duplication.TestScannerSelectionUsingKeyRange: the new cache service is never shut down.
|
on Claude 2. comment. Confirmed. There are no remaining callers of on Clause nit in The rest of the review was fixed. |
c6d4b7f to
2bb2bcd
Compare
|
Thanks @VladRodionov . I'm not sure about what has been changed exactly, I suggest to push multiple commits onto the PR in the future, rather than force pushing a single commit to get better visibility on the different changes. Let me share Claude's comments on the latest version.
Thanks for the quick turnaround and the explanations. I compared On your two replies:
A few small things from the update itself: 1. 2. 3. Nits
Once CI is green on this commit (and with a note on which test was flaky earlier), I'm happy to approve. |
Addressed the rest of a comments |
|
The failures are not PR-related. Verified locally two failed test: |

HBASE-30471 Remove LruBlockCache dependencies from test and production code
Summary
This PR continues the pluggable block cache migration by removing direct dependencies on
LruBlockCachefrom production and test code where the newCacheEngine/CacheAccessServiceAPIs can be used instead.The main goal is to move LRU-specific behavior and tests to
LruCacheEnginewhile keeping legacyBlockCacheimplementations supported through the existing compatibility adapters.This PR is based on
HBASE-30018and assumes theHBASE-30383RegionServerCacheAccessServicemigration is already present in that branch.Changes
TestLruBlockCachecoverage toTestLruCacheEngine.TestLruBlockCache.LruCacheEnginewith the functionality needed by the migrated unit tests.CacheEngine/CacheAccessServiceabstractionsinstead of depending directly on
LruBlockCache.BlockCacheTestUtilsfor test cases that still need to exercise legacyBlockCacheimplementations during the transition.
CacheTestUtils,CacheAccessServiceTestFactory, andCacheAccessServiceTestInstanceto support both legacyBlockCacheand newCacheEnginebased tests.
TopologyBackedCacheAccessServiceand related helpers where needed to expose thefunctionality required by migrated callers and tests.
than introducing new direct
LruBlockCachedependencies.Scope
This PR does not attempt to remove every remaining
BlockCachereference from HBase.BlockCacheis still required for legacy cache implementations and compatibility adapters that havenot yet been migrated. Those references will be removed incrementally as the remaining cache
implementations are converted.
The purpose of this change is specifically to eliminate unnecessary
LruBlockCachedependenciesfrom code that can now use the pluggable cache APIs.
Behavior
No user-visible cache behavior change is intended.
The changes are primarily an internal API and test migration from the concrete
LruBlockCacheimplementation toLruCacheEngine,CacheEngine, andCacheAccessService.Validation
The affected cache and HFile unit tests are exercised as part of this change, including the migrated
TestLruCacheEnginecoverage and tests for cache access, cache-on-write, HFile block handling,scanner behavior, and block encoding.
git diff --checkis clean.AI-assisted development
This change was developed in collaboration with ChatGPT 5.6 Sol. ChatGPT was used as a
development and review assistant for code migration, test adaptation, API design discussion, and
review feedback. All resulting code and design decisions were reviewed and validated by the author.