Skip to content

Commit

Permalink
fix NullPointerException in delete and clean files operation
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrn5 committed Apr 26, 2019
1 parent 7fd8dad commit cbff5c6
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ public static boolean isMaxQueryTimeoutExceeded(long fileTimestamp) {
private static boolean compareTimestampsAndDelete(
CarbonFile invalidFile,
boolean forceDelete, boolean isUpdateStatusFile) {
long fileTimestamp = 0L;
Long fileTimestamp = 0L;

if (isUpdateStatusFile) {
fileTimestamp = CarbonUpdateUtil.getTimeStampAsLong(invalidFile.getName()
Expand All @@ -683,6 +683,31 @@ private static boolean compareTimestampsAndDelete(
CarbonTablePath.DataFileUtil.getTimeStampFromFileName(invalidFile.getName()));
}

// This check is because, when there are some invalid files like tableStatusUpdate.write files
// present in store [[which can happen during delete or update if the disk is full or hdfs quota
// is finished]] then fileTimestamp will be null, in that case check for max query out and
// delete the .write file after timeout
if (fileTimestamp == null) {
String tableUpdateStatusFilename = invalidFile.getName();
if (tableUpdateStatusFilename.endsWith(".write")) {
long tableUpdateStatusFileTimeStamp = Long.parseLong(tableUpdateStatusFilename
.substring(tableUpdateStatusFilename.lastIndexOf(CarbonCommonConstants.HYPHEN) + 1,
invalidFile.getName().indexOf(".")));
if (isMaxQueryTimeoutExceeded(tableUpdateStatusFileTimeStamp)) {
try {
LOGGER.info("deleting the invalid .write file : " + invalidFile.getName());
CarbonUtil.deleteFoldersAndFiles(invalidFile);
return true;
} catch (IOException e) {
LOGGER.error("error in clean up of invalid .write files." + e.getMessage(), e);
} catch (InterruptedException e) {
LOGGER.error("error in clean up of invalid .write files." + e.getMessage(), e);
}
}
}
return false;
}

// if the timestamp of the file is more than the current time by query execution timeout.
// then delete that file.
if (CarbonUpdateUtil.isMaxQueryTimeoutExceeded(fileTimestamp) || forceDelete) {
Expand Down

0 comments on commit cbff5c6

Please sign in to comment.