Indhumathi27 commented on a change in pull request #4076: URL: https://github.com/apache/carbondata/pull/4076#discussion_r561714909
########## File path: core/src/main/java/org/apache/carbondata/core/view/MVProvider.java ########## @@ -569,14 +568,31 @@ private synchronized void touchMDTFile() throws IOException { FileFactory.createDirectoryAndSetPermission(this.systemDirectory, new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); } - CarbonFile schemaIndexFile = FileFactory.getCarbonFile(this.schemaIndexFilePath); - if (schemaIndexFile.exists()) { - schemaIndexFile.delete(); + // two or more JVM process can access this method to update last modified time at same + // time causing exception. So take a system level lock on system folder and update + // last modified time of schema index file + ICarbonLock systemDirLock = CarbonLockFactory + .getSystemLevelCarbonLockObj(this.systemDirectory, + LockUsage.MATERIALIZED_VIEW_STATUS_LOCK); + boolean locked = false; + try { + locked = systemDirLock.lockWithRetries(); + if (locked) { + CarbonFile schemaIndexFile = FileFactory.getCarbonFile(this.schemaIndexFilePath); + if (schemaIndexFile.exists()) { + schemaIndexFile.delete(); + } + schemaIndexFile.createNewFile(new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); + this.lastModifiedTime = schemaIndexFile.getLastModifiedTime(); + } else { + LOG.warn("Unable to get Lock to refresh schema index last modified time"); Review comment: Not needed, As next operation will compare last modified time and update it ---------------------------------------------------------------- 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: us...@infra.apache.org