-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-23222 MOB compaction supportability improvements #763
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/ManualMobMaintHFileCleaner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.hbase.mob; | ||
|
||
import java.util.concurrent.ConcurrentMap; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileStatus; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.hbase.HBaseInterfaceAudience; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.master.cleaner.BaseHFileCleanerDelegate; | ||
import org.apache.hadoop.hbase.util.FSUtils; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.apache.zookeeper.KeeperException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* {@link BaseHFileCleanerDelegate} that prevents cleaning HFiles from a mob region | ||
* | ||
* keeps a map of table name strings to mob region name strings over the life of | ||
* a JVM instance. if there's churn of unique table names we'll eat memory until | ||
* Master restart. | ||
*/ | ||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG) | ||
public class ManualMobMaintHFileCleaner extends BaseHFileCleanerDelegate { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(ManualMobMaintHFileCleaner.class); | ||
|
||
// We need to avoid making HRegionInfo objects for every table we check. | ||
private static final ConcurrentMap<TableName, String> MOB_REGIONS = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public boolean isFileDeletable(FileStatus fStat) { | ||
try { | ||
// if its a directory, then it can be deleted | ||
if (fStat.isDirectory()) return true; | ||
|
||
Path file = fStat.getPath(); | ||
|
||
// we need the table and region to determine if this is from a mob region | ||
// we don't need to worry about hfilelink back references, because the hfilelink cleaner will retain them. | ||
Path family = file.getParent(); | ||
Path region = family.getParent(); | ||
Path table = region.getParent(); | ||
|
||
TableName tableName = FSUtils.getTableName(table); | ||
|
||
String mobRegion = MOB_REGIONS.get(tableName); | ||
if (mobRegion == null) { | ||
String tmp = MobUtils.getMobRegionInfo(tableName).getEncodedName(); | ||
if (tmp == null) { | ||
LOG.error("couldn't determine mob region for table {} keeping files just in case.", tableName); | ||
return false; | ||
} | ||
mobRegion = MOB_REGIONS.putIfAbsent(tableName, tmp); | ||
// a return of null means that tmp is now in the map for future lookups. | ||
if (mobRegion == null) { | ||
mobRegion = tmp; | ||
} | ||
LOG.debug("Had to calculate name of mob region for table {} and it is {}", tableName, mobRegion); | ||
} | ||
|
||
boolean ret = !mobRegion.equals(region.getName()); | ||
if (LOG.isDebugEnabled() && !ret) { | ||
LOG.debug("Keeping file '{}' because it is from mob dir", fStat.getPath()); | ||
} | ||
return ret; | ||
} catch (RuntimeException e) { | ||
LOG.error("Failed to determine mob status of '{}', keeping it just in case.", fStat.getPath(), e); | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When are we removing elements from
MOB_REGIONS
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the intention here is to retain mob files indefinitely, for as long as this class is set in hbase.master.hfilecleaner.plugins config property? That's my taking from the class javadoc comment:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, we never do. I tried to warn about the consequences for this in the javadoc. Namely how creating lots of short lived tables with unique names will eat memory until a master restart happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sound fine @meszibalu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen the javadoc :( Ok, it sounds good to me.