NullPointer is getting thrown when rename table and select query is fired concurrently
Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/bcd28391 Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/bcd28391 Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/bcd28391 Branch: refs/heads/branch-1.1 Commit: bcd28391a6052954994513b0583397bc9c50ae8d Parents: f7d7e41 Author: nareshpr <prnaresh.nar...@gmail.com> Authored: Wed Apr 5 12:36:45 2017 +0530 Committer: ravipesala <ravi.pes...@gmail.com> Committed: Thu Apr 13 16:21:01 2017 +0530 ---------------------------------------------------------------------- .../cache/dictionary/AbstractDictionaryCache.java | 16 ++++++++++------ .../apache/carbondata/hadoop/util/SchemaReader.java | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/bcd28391/core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java b/core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java index cc4fc14..d7c25f1 100644 --- a/core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java +++ b/core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java @@ -126,15 +126,19 @@ public abstract class AbstractDictionaryCache<K extends DictionaryColumnUniqueId * @return */ private CarbonFile getDictionaryMetaCarbonFile( - DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) { + DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) throws IOException { PathService pathService = CarbonCommonFactory.getPathService(); CarbonTablePath carbonTablePath = pathService.getCarbonTablePath(carbonStorePath, - dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier()); - String dictionaryFilePath = - carbonTablePath.getDictionaryMetaFilePath(dictionaryColumnUniqueIdentifier - .getColumnIdentifier().getColumnId()); + dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier()); + String dictionaryFilePath = carbonTablePath.getDictionaryMetaFilePath( + dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId()); FileFactory.FileType fileType = FileFactory.getFileType(dictionaryFilePath); - return FileFactory.getCarbonFile(dictionaryFilePath, fileType); + CarbonFile dictFile = FileFactory.getCarbonFile(dictionaryFilePath, fileType); + // When rename table triggered parallely with select query, dictionary files may not exist + if (!dictFile.exists()) { + throw new IOException("Dictionary file does not exist: " + dictionaryFilePath); + } + return dictFile; } /** http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/bcd28391/hadoop/src/main/java/org/apache/carbondata/hadoop/util/SchemaReader.java ---------------------------------------------------------------------- diff --git a/hadoop/src/main/java/org/apache/carbondata/hadoop/util/SchemaReader.java b/hadoop/src/main/java/org/apache/carbondata/hadoop/util/SchemaReader.java index 022b3bb..f6c9e59 100644 --- a/hadoop/src/main/java/org/apache/carbondata/hadoop/util/SchemaReader.java +++ b/hadoop/src/main/java/org/apache/carbondata/hadoop/util/SchemaReader.java @@ -67,7 +67,7 @@ public class SchemaReader { return CarbonMetadata.getInstance().getCarbonTable( identifier.getCarbonTableIdentifier().getTableUniqueName()); } else { - return null; + throw new IOException("File does not exist: " + schemaFilePath); } } }