You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by GitBox <gi...@apache.org> on 2019/11/06 07:23:44 UTC

[GitHub] [carbondata] jackylk commented on a change in pull request #3435: [CARBONDATA-3571] Add table status file read retry for query

jackylk 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_r342946516
 
 

 ##########
 File path: core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
 ##########
 @@ -254,33 +260,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;
+    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
+          Thread.sleep(10);
 
 Review comment:
   ok

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services