[
https://issues.apache.org/jira/browse/HIVE-24275?focusedWorklogId=503379&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-503379
]
ASF GitHub Bot logged work on HIVE-24275:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Oct/20 20:10
Start Date: 21/Oct/20 20:10
Worklog Time Spent: 10m
Work Description: kishendas commented on a change in pull request #1583:
URL: https://github.com/apache/hive/pull/1583#discussion_r509643679
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Cleaner.java
##########
@@ -244,7 +249,32 @@ private void removeFiles(String location, ValidWriteIdList
writeIdList, Compacti
obsoleteDirs.addAll(dir.getAbortedDirectories());
List<Path> filesToDelete = new ArrayList<>(obsoleteDirs.size());
StringBuilder extraDebugInfo = new StringBuilder("[");
+ boolean delayedCleanupEnabled =
conf.getBoolVar(HiveConf.ConfVars.HIVE_COMPACTOR_DELAYED_CLEANUP_ENABLED);
+
for (Path stat : obsoleteDirs) {
+ if (delayedCleanupEnabled) {
+ String filename = stat.toString();
+ if (filename.startsWith(AcidUtils.BASE_PREFIX)) {
+ long writeId = AcidUtils.ParsedBase.parseBase(stat).getWriteId();
+ if (ci.type == CompactionType.MINOR) {
+ LOG.info("Skipping base dir " + stat + " as this cleanup is for
minor compaction"
+ + ", compaction id " + ci.id);
+ continue;
+ } else if (writeId > writeIdList.getHighWatermark()) {
+ LOG.info("Skipping base dir " + stat + " deletion as WriteId of
this base dir is"
+ + " greater than highWaterMark for compaction id " + ci.id);
+ continue;
+ }
+ }
+ else if (filename.startsWith(AcidUtils.DELTA_PREFIX) ||
filename.startsWith(AcidUtils.DELETE_DELTA_PREFIX)) {
+ AcidUtils.ParsedDelta delta = AcidUtils.parsedDelta(stat, fs);
+ if (delta.getMaxWriteId() > writeIdList.getHighWatermark()) {
Review comment:
Please add relevant comments in the code, wherever its not very obvious.
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Cleaner.java
##########
@@ -244,7 +249,32 @@ private void removeFiles(String location, ValidWriteIdList
writeIdList, Compacti
obsoleteDirs.addAll(dir.getAbortedDirectories());
List<Path> filesToDelete = new ArrayList<>(obsoleteDirs.size());
StringBuilder extraDebugInfo = new StringBuilder("[");
+ boolean delayedCleanupEnabled =
conf.getBoolVar(HiveConf.ConfVars.HIVE_COMPACTOR_DELAYED_CLEANUP_ENABLED);
+
for (Path stat : obsoleteDirs) {
+ if (delayedCleanupEnabled) {
+ String filename = stat.toString();
+ if (filename.startsWith(AcidUtils.BASE_PREFIX)) {
+ long writeId = AcidUtils.ParsedBase.parseBase(stat).getWriteId();
+ if (ci.type == CompactionType.MINOR) {
+ LOG.info("Skipping base dir " + stat + " as this cleanup is for
minor compaction"
+ + ", compaction id " + ci.id);
+ continue;
+ } else if (writeId > writeIdList.getHighWatermark()) {
+ LOG.info("Skipping base dir " + stat + " deletion as WriteId of
this base dir is"
+ + " greater than highWaterMark for compaction id " + ci.id);
+ continue;
+ }
+ }
+ else if (filename.startsWith(AcidUtils.DELTA_PREFIX) ||
filename.startsWith(AcidUtils.DELETE_DELTA_PREFIX)) {
+ AcidUtils.ParsedDelta delta = AcidUtils.parsedDelta(stat, fs);
Review comment:
It would be helpful to extract this logic to a separate method.
##########
File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
##########
@@ -3058,6 +3058,11 @@ private static void
populateLlapDaemonVarsSet(Set<String> llapDaemonVarsSetLocal
HIVE_COMPACTOR_CLEANER_RUN_INTERVAL("hive.compactor.cleaner.run.interval",
"5000ms",
new TimeValidator(TimeUnit.MILLISECONDS), "Time between runs of the
cleaner thread"),
+
HIVE_COMPACTOR_DELAYED_CLEANUP_ENABLED("hive.compactor.delayed.cleanup.enabled",
false,
+ "When enabled, cleanup of obsolete files/dirs after compaction can be
delayed. This delay \n" +
+ " can be configured by hive configuration
hive.compactor.cleaner.retention.time.seconds"),
+
HIVE_COMPACTOR_CLEANER_RETENTION_TIME_SECONDS("hive.compactor.cleaner.retention.time.seconds",
"300s",
Review comment:
It might be better to change the name to
"HIVE_COMPACTOR_CLEANER_RETENTION_TIME", since the value would indicate whether
it's in seconds or milliseconds.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 503379)
Time Spent: 1h 10m (was: 1h)
> Configurations to delay the deletion of obsolete files by the Cleaner
> ---------------------------------------------------------------------
>
> Key: HIVE-24275
> URL: https://issues.apache.org/jira/browse/HIVE-24275
> Project: Hive
> Issue Type: New Feature
> Reporter: Kishen Das
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> Whenever compaction happens, the cleaner immediately deletes older obsolete
> files. In certain cases it would be beneficial to retain these for certain
> period. For example : if you are serving the file metadata from cache and
> don't want to invalidate the cache during compaction because of performance
> reasons.
> For this purpose we should introduce a configuration
> hive.compactor.delayed.cleanup.enabled, which if enabled will delay the
> cleaning up obsolete files. There should be a separate configuration
> CLEANER_RETENTION_TIME to specify the duration till which we should retain
> these older obsolete files.
> It might be beneficial to have one more configuration to decide whether to
> retain files involved in an aborted transaction
> hive.compactor.aborted.txn.delayed.cleanup.enabled .
--
This message was sent by Atlassian Jira
(v8.3.4#803005)