Skip to content

Commit

Permalink
[IOTDB-470]fix IllegalArgumentException when there exists 0 byte TsFi…
Browse files Browse the repository at this point in the history
…le (#784)

* fix IllegalArgumentException when there exists 0 byte TsFile
  • Loading branch information
EJTTianYu committed Feb 11, 2020
1 parent e3f7437 commit 1013014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,17 @@ private void recover() throws StorageGroupProcessorException {
recoverUnseqFiles(unseqTsFiles);

for (TsFileResource resource : seqTsFiles) {
//After recover, case the TsFile's length is equal to 0, delete both the TsFileResource and the file itself
if (resource.getFile().length() == 0) {
deleteTsfile(resource.getFile());
}
allDirectFileVersions.addAll(resource.getHistoricalVersions());
}
for (TsFileResource resource : unseqTsFiles) {
//After recover, case the TsFile's length is equal to 0, delete both the TsFileResource and the file itself
if (resource.getFile().length() == 0) {
deleteTsfile(resource.getFile());
}
allDirectFileVersions.addAll(resource.getHistoricalVersions());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ public static ReadWriteLock getUpgradeLogLock() {
*/
public static boolean isNeedUpgrade(TsFileResource tsFileResource) {
tsFileResource.getWriteQueryLock().readLock().lock();
//case the TsFile's length is equal to 0, the TsFile does not need to be upgraded
if (tsFileResource.getFile().length() == 0) {
return false;
}
try (TsFileSequenceReader tsFileSequenceReader = new TsFileSequenceReader(
tsFileResource.getFile().getAbsolutePath())) {
if (tsFileSequenceReader.readVersionNumber().equals(TSFileConfig.OLD_VERSION)) {
return true;
}
} catch (IOException e) {
} catch (Exception e) {
logger.error("meet error when judge whether file needs to be upgraded, the file's path:{}",
tsFileResource.getFile().getAbsolutePath(), e);
} finally {
Expand Down

0 comments on commit 1013014

Please sign in to comment.