niuge01 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_r342896299
##########
File path: core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
##########
@@ -254,33 +260,44 @@ 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--;
Review comment:
How about sleep a moment?
----------------------------------------------------------------
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