Skip to content

HBASE-30471 Remove LruBlockCache dependencies from test and production code - #8844

Open
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30471-remove-lrublockcache-dependencies
Open

VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30471-remove-lrublockcache-dependencies

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

HBASE-30471 Remove LruBlockCache dependencies from test and production code

Summary

This PR continues the pluggable block cache migration by removing direct dependencies on
LruBlockCache from production and test code where the new CacheEngine /
CacheAccessService APIs can be used instead.

The main goal is to move LRU-specific behavior and tests to LruCacheEngine while keeping legacy
BlockCache implementations supported through the existing compatibility adapters.

This PR is based on HBASE-30018 and assumes the HBASE-30383 RegionServer
CacheAccessService migration is already present in that branch.

Changes

  • Migrates the former TestLruBlockCache coverage to TestLruCacheEngine.
  • Removes TestLruBlockCache.
  • Extends LruCacheEngine with the functionality needed by the migrated unit tests.
  • Updates HFile/cache production code to use CacheEngine / CacheAccessService abstractions
    instead of depending directly on LruBlockCache.
  • Updates affected HFile and cache tests to work through the new cache abstractions.
  • Adds BlockCacheTestUtils for test cases that still need to exercise legacy BlockCache
    implementations during the transition.
  • Extends CacheTestUtils, CacheAccessServiceTestFactory, and
    CacheAccessServiceTestInstance to support both legacy BlockCache and new CacheEngine
    based tests.
  • Updates TopologyBackedCacheAccessService and related helpers where needed to expose the
    functionality required by migrated callers and tests.
  • Keeps compatibility with legacy cache implementations through the existing adapter layer rather
    than introducing new direct LruBlockCache dependencies.

Scope

This PR does not attempt to remove every remaining BlockCache reference from HBase.

BlockCache is still required for legacy cache implementations and compatibility adapters that have
not 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 LruBlockCache dependencies
from 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
LruBlockCache implementation to LruCacheEngine, CacheEngine, and
CacheAccessService.

Validation

The affected cache and HFile unit tests are exercised as part of this change, including the migrated
TestLruCacheEngine coverage and tests for cache access, cache-on-write, HFile block handling,
scanner behavior, and block encoding.

git diff --check is 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.

@VladRodionov

Copy link
Copy Markdown
Contributor Author

Failed test is flaky. PR is ready for review @anmolnar @taklwu

@VladRodionov

Copy link
Copy Markdown
Contributor Author

Ran PR through GPT Astra.

No actionable findings in PR #8844 at commit 897814a.
Reviewed all 23 changed files and relevant callers. Validation passed on Java 21: 208 tests across six focused suites, with no failures or skips, covering LRU behavior, cache factories, compression, encoding, scanner reference counts, and cache-on-write.
The full HBase test suite was not run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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);
@VladRodionov
VladRodionov force-pushed the HBASE-30471-remove-lrublockcache-dependencies branch from 897814a to c6d4b7f Compare November 10, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants