ajantha-bhat commented on a change in pull request #3435: [CARBONDATA-3571] Add 
table status file read retry for query
URL: https://github.com/apache/carbondata/pull/3435#discussion_r346736682
 
 

 ##########
 File path: 
core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
 ##########
 @@ -254,33 +261,51 @@ public ValidAndInvalidSegmentsInfo 
getValidAndInvalidSegments(Boolean isChildTab
     DataInputStream dataInputStream = null;
     BufferedReader buffReader = null;
     InputStreamReader inStream = null;
-    LoadMetadataDetails[] listOfLoadFolderDetailsArray;
+    LoadMetadataDetails[] loadFolderDetails = null;
     AtomicFileOperations fileOperation =
         AtomicFileOperationFactory.getAtomicFileOperations(tableStatusPath);
 
-    try {
-      if (!FileFactory.isFileExist(tableStatusPath, 
FileFactory.getFileType(tableStatusPath))) {
-        return new LoadMetadataDetails[0];
+    // When storing table status file in object store, reading of table status 
file may
+    // fail (receive EOFException) when table status file is being modifying
+    // so here we retry multiple times before throwing EOFException
+    int retry = READ_TABLE_STATUS_RETRY_COUNT;
+    while (retry > 0) {
+      try {
+        if (!FileFactory.isFileExist(tableStatusPath, 
FileFactory.getFileType(tableStatusPath))) {
+          return new LoadMetadataDetails[0];
+        }
+        dataInputStream = fileOperation.openForRead();
+        inStream = new InputStreamReader(dataInputStream, 
Charset.forName(DEFAULT_CHARSET));
+        buffReader = new BufferedReader(inStream);
+        loadFolderDetails = gsonObjectToRead.fromJson(buffReader, 
LoadMetadataDetails[].class);
+        retry = 0;
+      } catch (EOFException ex) {
+        retry--;
+        if (retry == 0) {
+          // we have retried several times, throw this exception to make the 
execution failed
+          LOG.error("Failed to read metadata of load after retry", ex);
+          throw ex;
+        }
+        try {
+          // sleep for some time before retry
+          TimeUnit.MICROSECONDS.sleep(10);
 
 Review comment:
   10 microseconds is enough to handle all the file system like (S3) ? 

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to