Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-25880 remove files from filesCompacting when clear compaction queue#3261
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
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
70a832c452ef7b191f643a928f67d5334bdd278f871358039File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -24,6 +24,7 @@ | ||
| import java.io.IOException; | ||
| import java.io.PrintWriter; | ||
| import java.io.StringWriter; | ||
| import java.util.Collection; | ||
| import java.util.Comparator; | ||
| import java.util.Iterator; | ||
| import java.util.Optional; | ||
| @@ -794,11 +795,27 @@ void shutdownLongCompactions(){ | ||
| } | ||
| public void clearLongCompactionsQueue() { | ||
| longCompactions.getQueue().clear(); | ||
| removeFromFilesCompacting(longCompactions); | ||
| } | ||
| public void clearShortCompactionsQueue() { | ||
| shortCompactions.getQueue().clear(); | ||
| removeFromFilesCompacting(shortCompactions); | ||
frostruan marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| private void removeFromFilesCompacting(ThreadPoolExecutor compactor) { | ||
| Iterator<Runnable> iter = compactor.getQueue().iterator(); | ||
| while (iter.hasNext()) { | ||
| Runnable runnable = iter.next(); | ||
| if (!(runnable instanceof CompactionRunner)) { | ||
| continue; | ||
| } | ||
| CompactionRunner runner = (CompactionRunner) runnable; | ||
saintstack marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (runner.compaction != null && runner.compaction.hasSelection()) { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No data race here? Not sure, just asking ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking a look on this PR. I don't think there is data race here. It's safe. Thanks. | ||
| Collection<HStoreFile> files = runner.compaction.getRequest().getFiles(); | ||
frostruan marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| runner.store.removeFromCompactingFiles(files); | ||
| iter.remove(); | ||
| } | ||
| } | ||
| } | ||
| public boolean isCompactionsEnabled() { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -54,6 +54,7 @@ | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.LongStream; | ||
| import com.google.errorprone.annotations.RestrictedApi; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
| @@ -1953,6 +1954,23 @@ private void addToCompactingFiles(Collection<HStoreFile> filesToAdd) { | ||
| Collections.sort(filesCompacting, storeEngine.getStoreFileManager().getStoreFileComparator()); | ||
| } | ||
| /** | ||
| * Remove the files from compacting files. This usually happens when we clear compaction queues. | ||
| */ | ||
| void removeFromCompactingFiles(Collection<HStoreFile> filesToRemove) { | ||
| synchronized (filesCompacting) { | ||
| filesCompacting.removeAll(filesToRemove); | ||
| } | ||
frostruan marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| @RestrictedApi(explanation = "Should only be called in tests", link = "", | ||
| allowedOnPath = ".*/src/test/.*|.*/TestCompaction.java") | ||
| List<HStoreFile> getFilesCompacting() { | ||
| synchronized (filesCompacting) { | ||
| return Lists.newArrayList(filesCompacting); | ||
| } | ||
| } | ||
| private void removeUnneededFiles() throws IOException { | ||
| if (!conf.getBoolean("hbase.store.delete.expired.storefile", true)) { | ||
| return; | ||
Uh oh!
There was an error while loading. Please reload this page.