Skip to content

HBASE-29668 Add row cache framework - #7398

Merged
wchevreuil merged 9 commits into
apache:HBASE-29585from
EungsopYoo:HBASE-29668
Feb 23, 2026
Merged

HBASE-29668 Add row cache framework#7398
wchevreuil merged 9 commits into
apache:HBASE-29585from
EungsopYoo:HBASE-29668

Conversation

@EungsopYoo

Copy link
Copy Markdown
Contributor

No description provided.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@wchevreuil

Copy link
Copy Markdown
Contributor

I see this PR got an unrelated commit. Do you want me to rebase this branch on top of master, @EungsopYoo? You can then just force push your initial commit to your remote branch.

@EungsopYoo

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil
I’ve rebased it myself. Do you mean like this?

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@EungsopYoo

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil
Could you continue reviewing this PR?

@wchevreuilwchevreuil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for submitting this PR @EungsopYoo and sorry for the long delayed response. Let's resume the discussions on this. Please refer to my comments below:

I think we should avoid putting row cache related logic on RSRpcServices, as RSRpcServices is mainly a proxy between RS/Region logic and the RPC layer.

The row cache would be a core component of RegionServer, so in that sense, it should be created and kept at HRegionServer, just like we do for BlockCache.

Since row cache would be used on region related operations, all access logic to it should be implemented at HRegion class. HRegionServer should expose its row cache to HRegion instances via the RegionServerServices (as it does with BlockCache, for instance).

package org.apache.hadoop.hbase.regionserver;

@org.apache.yetus.audience.InterfaceAudience.Private
public class RowCacheImpl implements RowCache {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: since we are not really doing anything here, can we remove this impl from this PR and focus only on the framework itself?

@EungsopYooEungsopYooFeb 10, 2026

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@EungsopYoo

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil
Understood. I’m currently on vacation, so I’ll review your comments next week.

@wchevreuil

Copy link
Copy Markdown
Contributor

@wchevreuil Understood. I’m currently on vacation, so I’ll review your comments next week.

No problem. Enjoy your time off!

@EungsopYoo

Copy link
Copy Markdown
ContributorAuthor

I have a lot of backlog, so I think I’ll be able to resume in about one to two weeks.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@EungsopYoo

Copy link
Copy Markdown
ContributorAuthor

@wchevreuil
The apache:HBASE-29585 branch was created a few months ago. So wouldn’t it be better to sync it with the latest changes before we start modifying it? What’s the best way to proceed?

Should I open a separate PR for the update, or could you take care of it directly?

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 12sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ HBASE-29585 Compile Tests _
+0 🆗mvndep0m 10sMaven dependency ordering for branch
+1 💚mvninstall2m 40sHBASE-29585 passed
+1 💚compile4m 4sHBASE-29585 passed
+1 💚checkstyle0m 55sHBASE-29585 passed
+1 💚spotbugs2m 15sHBASE-29585 passed
+1 💚spotless0m 41sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗mvndep0m 11sMaven dependency ordering for patch
+1 💚mvninstall2m 19sthe patch passed
+1 💚compile4m 0sthe patch passed
+1 💚javac4m 0sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
-0 ⚠️checkstyle0m 8s/buildtool-patch-checkstyle-hbase-server.txtThe patch fails to run checkstyle in hbase-server
-0 ⚠️rubocop0m 4s/results-rubocop.txtThe patch generated 2 new + 411 unchanged - 0 fixed = 413 total (was 411)
+1 💚spotbugs2m 27sthe patch passed
+1 💚hadoopcheck8m 48sPatch does not cause any errors with Hadoop 3.3.6 3.4.1.
+1 💚spotless0m 34spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 30sThe patch does not generate ASF License warnings.
36m 41s
SubsystemReport/Notes
DockerClientAPI=1.53 ServerAPI=1.53 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7398/14/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#7398
Optional Testsdupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless rubocop
unameLinux bacbee5c8d09 6.14.0-1018-aws #18~24.04.1-Ubuntu SMP Mon Nov 24 19:46:27 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionHBASE-29585 / 927b2e6
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count85 (vs. ulimit of 30000)
modulesC: hbase-common hbase-client hbase-server hbase-shell U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7398/14/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3 rubocop=1.37.1
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 36sDocker mode activated.
-0 ⚠️yetus0m 5sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ HBASE-29585 Compile Tests _
+0 🆗mvndep0m 21sMaven dependency ordering for branch
+1 💚mvninstall4m 27sHBASE-29585 passed
+1 💚compile1m 54sHBASE-29585 passed
+1 💚javadoc1m 12sHBASE-29585 passed
+1 💚shadedjars6m 7sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗mvndep0m 14sMaven dependency ordering for patch
+1 💚mvninstall2m 58sthe patch passed
+1 💚compile1m 55sthe patch passed
+1 💚javac1m 55sthe patch passed
+1 💚javadoc1m 11sthe patch passed
+1 💚shadedjars6m 1spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit2m 25shbase-common in the patch passed.
+1 💚unit1m 31shbase-client in the patch passed.
+1 💚unit230m 24shbase-server in the patch passed.
+1 💚unit7m 25shbase-shell in the patch passed.
275m 3s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7398/14/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#7398
Optional Testsjavac javadoc unit compile shadedjars
unameLinux 51b405efab84 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionHBASE-29585 / 927b2e6
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7398/14/testReport/
Max. process+thread count4435 (vs. ulimit of 30000)
modulesC: hbase-common hbase-client hbase-server hbase-shell U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7398/14/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@EungsopYoo
EungsopYoo marked this pull request as draft February 9, 2026 06:05
@EungsopYoo

EungsopYoo commented Feb 9, 2026

Copy link
Copy Markdown
ContributorAuthor

Thanks for submitting this PR @EungsopYoo and sorry for the long delayed response. Let's resume the discussions on this. Please refer to my comments below:

I think we should avoid putting row cache related logic on RSRpcServices, as RSRpcServices is mainly a proxy between RS/Region logic and the RPC layer.

The row cache would be a core component of RegionServer, so in that sense, it should be created and kept at HRegionServer, just like we do for BlockCache.

Since row cache would be used on region related operations, all access logic to it should be implemented at HRegion class. HRegionServer should expose its row cache to HRegion instances via the RegionServerServices (as it does with BlockCache, for instance).

4707c74

@EungsopYoo
EungsopYoo marked this pull request as ready for review February 9, 2026 08:02

RegionScannerImpl getScannerWithResults(Get get, Scan scan, List<Cell> results)
throws IOException {
return getRowCacheService().getScanner(this, get, scan, results);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'll always go for the row cache? What if it's disabled?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is determined in RowCacheService.getScanner(). If the row cache is disabled, the system falls back to the traditional read path.

Comment on lines +90 to +107
RegionScannerImpl getScanner(HRegion region, Get get, Scan scan, List<Cell> results)
throws IOException {
if (!canCacheRow(get, region)) {
return getScannerInternal(region, scan, results);
}

RowCacheKey key = new RowCacheKey(region, get.getRow());

// Try get from row cache
if (tryGetFromCache(region, key, get, results)) {
// Cache is hit, and then no scanner is created
return null;
}

RegionScannerImpl scanner = getScannerInternal(region, scan, results);
populateCache(region, results, key);
return scanner;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think RowCacheService shouldn't bother about RegionScannerImpl, but rather only the cache itself, so it should only check for the rowkey in the cache and populate the results accordingly. It's then up for the HRegion to create the scanner when no results are found in the row cache. So we could make this method void, or return List with the found results, and get rid of the scanner creation logic. These would be done in HRegion.getScannerResults.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +132 to +134
RegionScannerImpl scanner = region.getScanner(scan);
scanner.next(results);
return scanner;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should move to HRegion (see my previous comment above).

return getScannerInternal(region, scan, results);
}

RowCacheKey key = new RowCacheKey(region, get.getRow());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we use "namespace + tableame + rowkey" as the UID of a row in the row cache? We could then only pass the TableDescriptor, rather than the HRegion as this method parameter.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

If we want to support evicting the row cache when a region is closed, similar to how block cache eviction works, we need to include the region ID as part of the UID. Otherwise, it is impossible to determine which row cache entries are associated with the region being closed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a good point. Let's keep it as it is now (region name + row key).

@wchevreuilwchevreuil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, +1, just had some final nit comments.

this.isRowCacheEnabled = determineRowCacheEnabled();
}

boolean determineRowCacheEnabled() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: call it "checkRowCacheConfig()" and make it private.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

return false;
}

boolean tryGetFromCache(HRegion region, RowCacheKey key, Get get, List<Cell> results) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: no need for the region param anymore.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

return true;
}

void populateCache(HRegion region, List<Cell> results, RowCacheKey key) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: no need for the region param anymore.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@wchevreuil
wchevreuil merged commit 7c5fa67 into apache:HBASE-29585Feb 23, 2026
Sign up for freeto 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.

4 participants

@EungsopYoo@Apache-HBase@wchevreuil@terence-yoo