Skip to content

HBASE-30102 Add metric to account for region data classified as cold by the Time Based Priority logic#8128

Merged
wchevreuil merged 7 commits intoapache:masterfrom
wchevreuil:HBASE-30102
Apr 30, 2026
Merged

HBASE-30102 Add metric to account for region data classified as cold by the Time Based Priority logic#8128
wchevreuil merged 7 commits intoapache:masterfrom
wchevreuil:HBASE-30102

Conversation

@wchevreuil
Copy link
Copy Markdown
Contributor

No description provided.

…by the Time Based Priority logic

Change-Id: I5601a37300a3f5d10fe4886ba988f2d25e66b546
Change-Id: I8eb236beaf7976ccd02349aa81277ca84925e7e6
Copy link
Copy Markdown
Contributor

@taklwu taklwu left a comment

Choose a reason for hiding this comment

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

when Time Based Priority is disabled, what would be the % Cold Data? is it always showing?

getAllCacheKeysForFile(hFileInfo.getHFileContext().getHFileName(), 0, Long.MAX_VALUE);
int evictedBlocks = evictBlockSet(keySet);
if (evictedBlocks > 0) {
LOG.info("Evicted {} blocks for file {} as it is now considered cold by DataTieringManager",
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: should we have it as debug level? I'm wondered if we see a lot of these message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe, yeah. Although it would be triggered only upon enabling of the time based priority on the individual store, and once for each affected file, it can still flood the logs. Let me switch it to DEBUG.

Comment on lines +106 to +111
if (key.getCfName() != null) {
builder.setFamilyName(key.getCfName());
}
if (key.getRegionName() != null) {
builder.setRegionName(key.getRegionName());
}
Copy link
Copy Markdown
Contributor

@taklwu taklwu Apr 27, 2026

Choose a reason for hiding this comment

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

question: why weren't the cf and regionname filled before ? is it because the cold data needs for log message or other compute usage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is required not only by the new "coldDataRatio" metric we are adding, but also the existing "regionCachedRatio" that is critical for the CacheAwareLoadBalancer. Without this change here, we cannot calculate these metrics when recovering the persistent cache. IMO, it's a bug in the current CacheAwareLoadBalancer implementation.

Change-Id: I392517f882e7c5a8c6063b16f525f6467956a3bb
@wchevreuil wchevreuil requested a review from taklwu April 28, 2026 15:45
Copy link
Copy Markdown
Contributor

@taklwu taklwu left a comment

Choose a reason for hiding this comment

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

LGTM.

something is wrong with the github action, can you give a try to trigger them ?

@wchevreuil
Copy link
Copy Markdown
Contributor Author

when Time Based Priority is disabled, what would be the % Cold Data? is it always showing?

It would show as 0%. With the "% Cold Data" and "% Cached", operators can infer if there's indeed a problem with the region cache, as those are mutually exclusive, if both are low, it means the region caching went into some problems, most likely, not enough cache capacity.

for (HStoreFile file : newFiles) {
// call isHotData to account for the new file size in regionColdDataSize, if the new file is
// considered cold data as per data-tiering logic.
isHotData(file.getFileInfo().getHFileInfo(), file.getFileInfo().getConf());
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 this cause a deadlock? This part is inside regionColdDataSize.computeIfPresent block and the isHotData also runs regionColdDataSize.compute on the same ConcurrentMap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean, if another thread is calling isHotData? I don't think it would, which ever reaches the regionColdDataSize atomic methods first would own the lock and block the other, right?

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 checked this part with Claude and it gave this answer:

No — this is a single-thread deadlock. That's what makes it especially insidious.

One thread does this:

  1. Enters computeIfPresent(regionName, lambda) — acquires the internal bin lock
  2. Inside the lambda, calls isHotData(...)
  3. isHotData calls compute(regionName, lambda2) — tries to acquire the same bin lock
  4. The lock is non-reentrant, so the same thread blocks waiting on itself

It's not a classic two-thread deadlock — it's a single thread trying to re-acquire a lock it already holds, on a lock that doesn't support reentrancy. The thread hangs forever.

This will happen every time a compaction produces a new cold file in a region that already has cold data tracked. That's a normal steady-state scenario, not a rare race condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is true. I've added a UT that simulates the compaction resulting in new cold file (the scenario claude mentioned) and it doesn't dead lock.

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 taking a look and adding a unit test for it!

// to evict it.
Set<BlockCacheKey> keySet =
getAllCacheKeysForFile(hFileInfo.getHFileContext().getHFileName(), 0, Long.MAX_VALUE);
int evictedBlocks = evictBlockSet(keySet);
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 method name shouldCacheFile suggests this just a check but it actually evicts the blocks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, not ideal, but I still think it should be BucketCache responsibility to evict blocks from files that became classified as cold, upon changing time based priority configuration. Moving this to DataTieringManager would tighter couple it with BucketCache.

@wchevreuil
Copy link
Copy Markdown
Contributor Author

LGTM.

something is wrong with the github action, can you give a try to trigger them ?

Sure. I've run the failing tests locally, and it all passed. I'm trying another round here.

wchevreuil and others added 4 commits April 29, 2026 12:35
Co-authored-by: Peter Somogyi <psomogyi@cloudera.com>
Co-authored-by: Peter Somogyi <psomogyi@cloudera.com>
Change-Id: I2194da9f2d1e596ae76a0fa244a521a698ff13f9
Change-Id: I171bd2169c18ca47795d239af60ca2414410d060
@wchevreuil wchevreuil merged commit 01ca956 into apache:master Apr 30, 2026
8 checks passed
wchevreuil added a commit that referenced this pull request Apr 30, 2026
…by the Time Based Priority logic (#8128)

Signed-off-by: Peter Somogyi <psomogyi@apache.com>
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
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.

3 participants