Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

jhungund
Copy link
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.

vinayakphegde and 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
Contributor Author

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
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?

Copy link
Contributor Author

@jhungund jhungund Apr 18, 2024

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
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?

DataTieringManager.instantiate(onlineRegions);
blockCache = BlockCacheFactory.createBlockCache(conf);
Copy link
Contributor Author

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

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 41s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
_ HBASE-28463 Compile Tests _
+1 💚 mvninstall 4m 55s HBASE-28463 passed
+1 💚 compile 3m 20s HBASE-28463 passed
+1 💚 checkstyle 0m 41s HBASE-28463 passed
+1 💚 spotless 0m 52s branch has no errors when running spotless:check.
+1 💚 spotbugs 1m 53s HBASE-28463 passed
_ Patch Compile Tests _
+1 💚 mvninstall 3m 58s the patch passed
+1 💚 compile 3m 15s the patch passed
+1 💚 javac 3m 15s the patch passed
-0 ⚠️ checkstyle 0m 46s hbase-server: The patch generated 10 new + 85 unchanged - 0 fixed = 95 total (was 85)
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 hadoopcheck 6m 14s Patch does not cause any errors with Hadoop 3.3.6.
-1 ❌ spotless 1m 8s patch has 69 errors when running spotless:check, run spotless:apply to fix.
+1 💚 spotbugs 2m 45s the patch passed
_ Other Tests _
+1 💚 asflicense 0m 16s The patch does not generate ASF License warnings.
40m 38s
Subsystem Report/Notes
Docker ClientAPI=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 Issue HBASE-28527
Optional Tests dupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision HBASE-28463 / b7bb8b9
Default Java Eclipse Adoptium-11.0.17+8
checkstyle https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-general-check/output/diff-checkstyle-hbase-server.txt
spotless https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/artifact/yetus-general-check/output/patch-spotless.txt
Max. process+thread count 77 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versions git=2.34.1 maven=3.8.6 spotbugs=4.7.3
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 43s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ HBASE-28463 Compile Tests _
+1 💚 mvninstall 4m 54s HBASE-28463 passed
+1 💚 compile 1m 9s HBASE-28463 passed
+1 💚 shadedjars 6m 55s branch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 0m 44s HBASE-28463 passed
_ Patch Compile Tests _
+1 💚 mvninstall 3m 54s the patch passed
+1 💚 compile 0m 57s the patch passed
+1 💚 javac 0m 57s the patch passed
+1 💚 shadedjars 6m 33s patch has no errors when building our shaded downstream artifacts.
-0 ⚠️ javadoc 0m 27s hbase-server generated 1 new + 96 unchanged - 0 fixed = 97 total (was 96)
_ Other Tests _
+1 💚 unit 234m 25s hbase-server in the patch passed.
265m 3s
Subsystem Report/Notes
Docker ClientAPI=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 Issue HBASE-28527
Optional Tests javac javadoc unit shadedjars compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision HBASE-28463 / b7bb8b9
Default Java Eclipse Adoptium-11.0.17+8
javadoc https://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 Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/testReport/
Max. process+thread count 5198 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versions git=2.34.1 maven=3.8.6
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 57s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ HBASE-28463 Compile Tests _
+1 💚 mvninstall 2m 38s HBASE-28463 passed
+1 💚 compile 0m 42s HBASE-28463 passed
+1 💚 shadedjars 5m 10s branch has no errors when building our shaded downstream artifacts.
+1 💚 javadoc 0m 26s HBASE-28463 passed
_ Patch Compile Tests _
+1 💚 mvninstall 2m 25s the patch passed
+1 💚 compile 0m 42s the patch passed
+1 💚 javac 0m 42s the patch passed
+1 💚 shadedjars 5m 10s patch has no errors when building our shaded downstream artifacts.
-0 ⚠️ javadoc 0m 25s hbase-server generated 1 new + 22 unchanged - 0 fixed = 23 total (was 22)
_ Other Tests _
+1 💚 unit 245m 20s hbase-server in the patch passed.
268m 44s
Subsystem Report/Notes
Docker ClientAPI=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 Issue HBASE-28527
Optional Tests javac javadoc unit shadedjars compile
uname Linux 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 tool maven
Personality dev-support/hbase-personality.sh
git revision HBASE-28463 / b7bb8b9
Default Java Temurin-1.8.0_352-b08
javadoc https://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 Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/testReport/
Max. process+thread count 5281 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-5832/1/console
versions git=2.34.1 maven=3.8.6
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@wchevreuil
Copy link
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
Copy link
Contributor Author

jhungund commented Apr 18, 2024

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
Contributor

Choose a reason for hiding this comment

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

nit: unneeded change.

@@ -682,7 +683,7 @@ public void fileCacheCompleted(Path filePath, long size) {
}

private void updateRegionCachedSize(Path filePath, long cachedSize) {
if (filePath != null) {
if (filePath != null && filePath.getParent() != null && filePath.getParent().getParent() != null) {
Copy link
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
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
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.offset = offset;
this.blockType = blockType;
public BlockCacheKey(Path hfilePath, long offset) {
this(hfilePath, offset, true, BlockType.DATA);
}
Copy link
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
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
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
Contributor Author

Closing this PR in favour of PR #5829

@jhungund jhungund closed this Apr 24, 2024
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.

4 participants