Skip to content

HBASE-30161 Add paginated, single-RPC RegionLocator.getRegionLocations(startKey, limit) API for bulk meta-cache warmup#8237

Open
sanjeet006py wants to merge 3 commits into
apache:masterfrom
sanjeet006py:HBASE-30161-async-master
Open

HBASE-30161 Add paginated, single-RPC RegionLocator.getRegionLocations(startKey, limit) API for bulk meta-cache warmup#8237
sanjeet006py wants to merge 3 commits into
apache:masterfrom
sanjeet006py:HBASE-30161-async-master

Conversation

@sanjeet006py
Copy link
Copy Markdown
Contributor

JIRA: HBASE-30161

Generated-by: Claude Opus 4.7

Sanjeet Malhotra added 3 commits May 14, 2026 22:21
…s(startKey, limit) API for bulk meta-cache warmup
… and add default-throws

Review comments on apache#8236 by haridsv:
- Adding an abstract method to RegionLocator / AsyncTableRegionLocator breaks
  external implementers. Convert the new method to a default that throws
  UnsupportedOperationException, with javadoc instructing callers to fall
  back to getAllRegionLocations().
- Reusing the getRegionLocations name overloads a method with completely
  different semantic (row -> all replicas of containing region). Rename to
  getRegionLocationsPage(byte[] startKey, int limit) to make the
  pagination/range intent explicit.
- SnapshotRegionLocator no longer needs an override; it inherits the
  default-throws and callers fall back to getAllRegionLocations().

Tests renamed to call getRegionLocationsPage; semantic and assertions
unchanged.
Address point apache#4 of the canvas/code review: the paged meta scan was making
ceil(limit / hbase.meta.scanner.caching) ScannerNext RPCs whenever the
limit exceeded the configured caching, contradicting the
"at most one RPC per invocation" javadoc on
RegionLocator.getRegionLocationsPage / AsyncTableRegionLocator.getRegionLocationsPage.

Plumb a private isPagedScan flag through ClientMetaTableAccessor.scanMeta
and getMetaScan. When true, size both setLimit and setCaching to the
caller-supplied rowUpperLimit so the slice returns in a single ScannerNext
RPC regardless of the configured caching default. The unbounded scanMeta
overload (used by getTableHRegionLocations(metaTable, tableName) for
getAllRegionLocations) keeps its existing behavior.

Add TestRegionLocatorPagedScanRpcCount: starts a mini-cluster with
hbase.meta.scanner.caching=2, wraps the meta AsyncTable to count
AdvancedScanResultConsumer.onNext invocations, and asserts:
- limit <= caching   -> 1 ScannerNext (baseline)
- limit > caching    -> 1 ScannerNext (the regression check)
- unbounded scan     -> ceil(N / caching) ScannerNext (proves the flag
                        does not leak into the existing path)

Verified the test catches the regression: reverting the getMetaScan
change makes testSingleRpcWhenLimitExceedsCaching fail with onNext=3.
sanjeet006py pushed a commit to sanjeet006py/hbase that referenced this pull request May 15, 2026
…scans

Mirrors the master-PR test (TestRegionLocatorPagedScanRpcCount on
apache#8237). On the sync path we proxy:

  Connection.getTable(META_TABLE_NAME) -> Table.getScanner(Scan) ->
  ResultScanner.close()

so we can flip Scan.setScanMetricsEnabled(true) on the way in and read
ScanMetrics.countOfRPCcalls before the underlying scanner is closed. The
RPC count is the natural sync analogue of the
AdvancedScanResultConsumer.onNext invocation count we used on master.

Cluster runs with hbase.meta.scanner.caching = 2 against a table of
5 user regions, asserting:
- limit <= caching: 1 ScannerNext RPC (baseline)
- limit > caching: 1 ScannerNext RPC (regression check; without the
                   isPagedScan fix this would be ceil(5/2) = 3)
- unbounded scan:  ceil(NUM_REGIONS / caching) = 3 ScannerNext RPCs
                   (proves the isPagedScan flag does not leak into the
                   non-paged callers)

Verified the test catches the regression: reverting the isPagedScan
branch in MetaTableAccessor.getMetaScan makes
testSingleRpcWhenLimitExceedsCaching fail with countOfRPCcalls = 3.
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.

1 participant