[GitHub] [flink] JingsongLi commented on a change in pull request #12651: [FLINK-18272][table-runtime-blink] Add retry logic to FileSystemLooku…

2020-06-15 Thread GitBox


JingsongLi commented on a change in pull request #12651:
URL: https://github.com/apache/flink/pull/12651#discussion_r440590714



##
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemLookupFunction.java
##
@@ -143,26 +148,41 @@ private void checkCacheReload() {
} else {
LOG.info("Populating lookup join cache");
}
-   cache.clear();
-   try {
-   T[] inputSplits = inputFormat.createInputSplits(1);
-   GenericRowData reuse = new 
GenericRowData(producedNames.length);
-   long count = 0;
-   for (T split : inputSplits) {
-   inputFormat.open(split);
-   while (!inputFormat.reachedEnd()) {
-   RowData row = 
inputFormat.nextRecord(reuse);
-   count++;
-   Row key = extractKey(row);
-   List rows = 
cache.computeIfAbsent(key, k -> new ArrayList<>());
-   rows.add(serializer.copy(row));
+   int numRetry = 0;
+   while (true) {
+   cache.clear();
+   try {
+   T[] inputSplits = 
inputFormat.createInputSplits(1);
+   GenericRowData reuse = new 
GenericRowData(producedNames.length);
+   long count = 0;
+   for (T split : inputSplits) {
+   inputFormat.open(split);
+   while (!inputFormat.reachedEnd()) {
+   RowData row = 
inputFormat.nextRecord(reuse);
+   count++;
+   Row key = extractKey(row);
+   List rows = 
cache.computeIfAbsent(key, k -> new ArrayList<>());
+   rows.add(serializer.copy(row));
+   }
+   inputFormat.close();
+   }
+   nextLoadTime = System.currentTimeMillis() + 
getCacheTTL().toMillis();
+   LOG.info("Loaded {} row(s) into lookup join 
cache", count);
+   return;
+   } catch (IOException e) {
+   if (numRetry >= MAX_RETRIES) {
+   throw new FlinkRuntimeException(
+   String.format("Failed 
to load table into cache after %d retries", numRetry), e);
+   }
+   long toSleep = ++numRetry * 
RETRY_INTERVAL.toMillis();

Review comment:
   One single line to `numRetry ++`





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




[GitHub] [flink] JingsongLi commented on a change in pull request #12651: [FLINK-18272][table-runtime-blink] Add retry logic to FileSystemLooku…

2020-06-15 Thread GitBox


JingsongLi commented on a change in pull request #12651:
URL: https://github.com/apache/flink/pull/12651#discussion_r440590313



##
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemLookupFunction.java
##
@@ -59,6 +59,11 @@
 
private static final Logger LOG = 
LoggerFactory.getLogger(FileSystemLookupFunction.class);
 
+   // the max number of retries before throwing exception, in case of 
failure to load the table into cache
+   private static final int MAX_RETRIES = 3;
+   // interval between retries
+   private static final Duration RETRY_INTERVAL = Duration.ofSeconds(1);

Review comment:
   10 sec?





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