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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

GitBox
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_r346809545
 
 

 ##########
 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:
   That was wrong, I changed it to `TimeUnit.MILLISECONDS.sleep(10);`

----------------------------------------------------------------
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:
[hidden email]


With regards,
Apache Git Services