Skip to content

HBASE-28527: Adjust BlockCacheKey to use the file path instead of file name. - #5832

Closed
jhungund wants to merge 3 commits into
apache:HBASE-28463from
janardhanrh:HBASE-28527
Closed

HBASE-28527: Adjust BlockCacheKey to use the file path instead of file name.#5832
jhungund wants to merge 3 commits into
apache:HBASE-28463from
janardhanrh:HBASE-28527

Conversation

@jhungund

Copy link
Copy Markdown
Contributor

The time-based priority eviction policy relies on the presence of path in
the BlockCacheKey to fetch the required metadata to check data hotness and
decide whether or not to retain the block in the bucket cache.

Hence, the constructor of BlockCacheKey is adjusted to take the file path
as the input parameter. The code paths that create the blockCacheKey and
also the unit tests need to be adjusted to pass the path instead of file name.

vinayakphegdeand others added 3 commits April 12, 2024 09:59
…t-cache (apache#5793)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…or Time Range Data Tiering (apache#5809)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…e name.
The time-based priority eviction policy relies on the presence of path in
the BlockCacheKey to fetch the required metadata to check data hotness and
decide whether or not to retain the block in the bucket cache.
Hence, the constructor of BlockCacheKey is adjusted to take the file path
as the input parameter. The code paths that create the blockCacheKey and
also the unit tests need to be adjusted to pass the path instead of file name.
Change-Id: I2d9b194756797b5ec53aaf6cfb8135cc515d49a8
key = new BlockCacheKey(allFilePaths.get(protoKey.getHfilename()), protoKey.getOffset(),
protoKey.getPrimaryReplicaBlock(), fromPb(protoKey.getBlockType()));
} else {
key = new BlockCacheKey(new Path(protoKey.getHfilename()), protoKey.getOffset(),

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 call will set the file name appropriately to protoKey.getHfilename().

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.

The path will be incorrect, right? Anyone who accesses it will find the incorrect path.
However, I couldn't think of any solution for that. @wchevreuil, do you have any thoughts?

@jhungundjhungundApr 18, 2024

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.

One way I can think of avoiding incorrect path to be set is by adding the following check in the constructor of BlockCacheKey:
if (hfilePath.getParent() != null) { this.filePath = hfilePath; }
But with this, path will remain null and during evictions (freespace()), either we should skip the data tiering logic for such blocks or take an expensive route of going over each file of the region server to determine the metadata. If the later case happens even for a single key, then, we are better off without the path and use the file names itself. Thoughts?

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.

In which cases will allFilesPath be non null? If it's whenever data tiering isn't TIME_RANGE, I think it's ok to don't bother about file path. In those cases though, I think we should use the fileName version of the cache key constructor.

And when it isn't null, what do we do with keys that weren't found in allFilesPath?


blockCache = BlockCacheFactory.createBlockCache(conf);
DataTieringManager.instantiate(onlineRegions);
blockCache = BlockCacheFactory.createBlockCache(conf);

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.

Instantiation of Data tiering manager is required to read the cache from persistence. Hence, change the order here.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 41sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 1sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ HBASE-28463 Compile Tests _
+1 💚mvninstall4m 55sHBASE-28463 passed
+1 💚compile3m 20sHBASE-28463 passed
+1 💚checkstyle0m 41sHBASE-28463 passed
+1 💚spotless0m 52sbranch has no errors when running spotless:check.
+1 💚spotbugs1m 53sHBASE-28463 passed
_ Patch Compile Tests _
+1 💚mvninstall3m 58sthe patch passed
+1 💚compile3m 15sthe patch passed
+1 💚javac3m 15sthe patch passed
-0 ⚠️checkstyle0m 46shbase-server: The patch generated 10 new + 85 unchanged - 0 fixed = 95 total (was 85)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚hadoopcheck6m 14sPatch does not cause any errors with Hadoop 3.3.6.
-1 ❌spotless1m 8spatch has 69 errors when running spotless:check, run spotless:apply to fix.
+1 💚spotbugs2m 45sthe patch passed
_ Other Tests _
+1 💚asflicense0m 16sThe patch does not generate ASF License warnings.
40m 38s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#5832
JIRA IssueHBASE-28527
Optional Testsdupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
unameLinux 14b3ea56ed94 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-28463 / b7bb8b9
Default JavaEclipse Adoptium-11.0.17+8
checkstylehttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-general-check/output/diff-checkstyle-hbase-server.txt
spotlesshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-general-check/output/patch-spotless.txt
Max. process+thread count77 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versionsgit=2.34.1 maven=3.8.6 spotbugs=4.7.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 43sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ HBASE-28463 Compile Tests _
+1 💚mvninstall4m 54sHBASE-28463 passed
+1 💚compile1m 9sHBASE-28463 passed
+1 💚shadedjars6m 55sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 44sHBASE-28463 passed
_ Patch Compile Tests _
+1 💚mvninstall3m 54sthe patch passed
+1 💚compile0m 57sthe patch passed
+1 💚javac0m 57sthe patch passed
+1 💚shadedjars6m 33spatch has no errors when building our shaded downstream artifacts.
-0 ⚠️javadoc0m 27shbase-server generated 1 new + 96 unchanged - 0 fixed = 97 total (was 96)
_ Other Tests _
+1 💚unit234m 25shbase-server in the patch passed.
265m 3s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR#5832
JIRA IssueHBASE-28527
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 33900618b5c9 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-28463 / b7bb8b9
Default JavaEclipse Adoptium-11.0.17+8
javadochttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-jdk11-hadoop3-check/output/diff-javadoc-javadoc-hbase-server.txt
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/testReport/
Max. process+thread count5198 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 57sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ HBASE-28463 Compile Tests _
+1 💚mvninstall2m 38sHBASE-28463 passed
+1 💚compile0m 42sHBASE-28463 passed
+1 💚shadedjars5m 10sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 26sHBASE-28463 passed
_ Patch Compile Tests _
+1 💚mvninstall2m 25sthe patch passed
+1 💚compile0m 42sthe patch passed
+1 💚javac0m 42sthe patch passed
+1 💚shadedjars5m 10spatch has no errors when building our shaded downstream artifacts.
-0 ⚠️javadoc0m 25shbase-server generated 1 new + 22 unchanged - 0 fixed = 23 total (was 22)
_ Other Tests _
+1 💚unit245m 20shbase-server in the patch passed.
268m 44s
SubsystemReport/Notes
DockerClientAPI=1.45 ServerAPI=1.45 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-jdk8-hadoop3-check/output/Dockerfile
GITHUB PR#5832
JIRA IssueHBASE-28527
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 8b82e32a7389 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionHBASE-28463 / b7bb8b9
Default JavaTemurin-1.8.0_352-b08
javadochttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-jdk8-hadoop3-check/output/diff-javadoc-javadoc-hbase-server.txt
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/testReport/
Max. process+thread count5281 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@wchevreuil

Copy link
Copy Markdown
Contributor

The time-based priority eviction policy relies on the presence of path in
the BlockCacheKey to fetch the required metadata to check data hotness and
decide whether or not to retain the block in the bucket cache.

Can you explain why do you need that? This is not a simple/small change.

@jhungund

jhungund commented Apr 18, 2024

Copy link
Copy Markdown
ContributorAuthor

The time-based priority eviction policy relies on the presence of path in
the BlockCacheKey to fetch the required metadata to check data hotness and
decide whether or not to retain the block in the bucket cache.

Can you explain why do you need that? This is not a simple/small change.

Hi @wchevreuil,
Thank you for reviewing the code.

Our design originally relied on the presence of path in the BlockCacheKey so that we parse the path to get to the regionID and column family to reach to the file and access its metadata. (The framework that @vinayakphegde has implemented).
The purpose of using the path is slightly avoid the overhead of traversing through the regions and column families and their files, if we rely on the filenames to fetch the corresponding metadata.

However, what we found is that path may or may not be always populated by the callers who instantiate BlockCacheKey.
Hence, this change enforces the users and also unit tests to always instantiate/create BlockCacheKey using the paths.
Hence, this change turned out to be a big change.

An alternative to this is another approach that relies only on the file name which is always present in the BlockCacheKey. With this approach, we do not make any changes in the callers of BlockcacheKey or the unit tests.
During cacheEvictions (freeSpace), we will require one traversal through all the files. I had tried to implement this approach in another change: #5829

Please take a look and let me know your idea about the same.


public BlockCacheKey(Path hfilePath, long offset, boolean isPrimaryReplica, BlockType blockType) {
this.filePath = hfilePath;
this.isPrimaryReplicaBlock = isPrimaryReplica;

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: unneeded change.


private void updateRegionCachedSize(Path filePath, long cachedSize) {
if (filePath != null) {
if (filePath != null && filePath.getParent() != null && filePath.getParent().getParent() != null) {

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.

Is this really possible?

DataTieringManager dataTieringManager;
try {
dataTieringManager = DataTieringManager.getInstance();
allFilePaths = dataTieringManager.getAllFilesList();

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 don't need this for non TIME_RANGE tiering type, right? Can we avoid it, then?

Comment on lines +146 to +148
// Data-Tiering manager has not been set up.
// Ignore the error and proceed with the normal flow.
LOG.warn("Error while getting DataTieringManager instance: {}", e.getMessage());

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.

Is this going to be thrown whenever data tiering type isn't set to TIME_RANGE?

this.blockType = blockType;
public BlockCacheKey(Path hfilePath, long offset) {
this(hfilePath, offset, true, BlockType.DATA);
}

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.

Can we just leave these and avoid having to touch every single existing test? As having a complete path is only relevant for the TIME_RANGE data tiering, I think it's fine to allow non complete paths when TIME_RANGE data tiering is not in use.


BlockCacheKey key = null;
if (allFilePaths != null) {
key = new BlockCacheKey(allFilePaths.get(protoKey.getHfilename()), protoKey.getOffset(),

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.

allFilePaths.get(protoKey.getHfilename()) may yield a null value, if we are recovering from a crash where we didn't have a chance to save the persistent index after a given file may have been removed.

key = new BlockCacheKey(allFilePaths.get(protoKey.getHfilename()), protoKey.getOffset(),
protoKey.getPrimaryReplicaBlock(), fromPb(protoKey.getBlockType()));
} else {
key = new BlockCacheKey(new Path(protoKey.getHfilename()), protoKey.getOffset(),

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.

In which cases will allFilesPath be non null? If it's whenever data tiering isn't TIME_RANGE, I think it's ok to don't bother about file path. In those cases though, I think we should use the fileName version of the cache key constructor.

And when it isn't null, what do we do with keys that weren't found in allFilesPath?

@jhungund

Copy link
Copy Markdown
ContributorAuthor

Closing this PR in favour of PR #5829

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

@jhungund@Apache-HBase@wchevreuil@vinayakphegde