johnyangk closed pull request #161: [NEMO-300] Fix starvation when handling multiple pending data fetchers URL: https://github.com/apache/incubator-nemo/pull/161
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/TaskExecutor.java b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/TaskExecutor.java index b08b12a25..af3197999 100644 --- a/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/TaskExecutor.java +++ b/runtime/executor/src/main/java/org/apache/nemo/runtime/executor/task/TaskExecutor.java @@ -461,31 +461,34 @@ private boolean handleDataFetchers(final List<DataFetcher> fetchers) { final Iterator<DataFetcher> pendingIterator = pendingFetchers.iterator(); final long currentTime = System.currentTimeMillis(); - // We check pending data every polling interval - while (pendingIterator.hasNext() - && isPollingTime(pollingInterval, currentTime, prevPollingTime)) { + + + if (isPollingTime(pollingInterval, currentTime, prevPollingTime)) { + // We check pending data every polling interval prevPollingTime = currentTime; - final DataFetcher dataFetcher = pendingIterator.next(); - try { - final Object element = dataFetcher.fetchDataElement(); - onEventFromDataFetcher(element, dataFetcher); + while (pendingIterator.hasNext()) { + final DataFetcher dataFetcher = pendingIterator.next(); + try { + final Object element = dataFetcher.fetchDataElement(); + onEventFromDataFetcher(element, dataFetcher); + + // We processed data. This means the data fetcher is now available. + // Add current data fetcher to available + pendingIterator.remove(); + if (!(element instanceof Finishmark)) { + availableFetchers.add(dataFetcher); + } - // We processed data. This means the data fetcher is now available. - // Add current data fetcher to available - pendingIterator.remove(); - if (!(element instanceof Finishmark)) { - availableFetchers.add(dataFetcher); + } catch (final NoSuchElementException e) { + // The current data fetcher is still pending.. try next data fetcher + } catch (final IOException e) { + // IOException means that this task should be retried. + taskStateManager.onTaskStateChanged(TaskState.State.SHOULD_RETRY, + Optional.empty(), Optional.of(TaskState.RecoverableTaskFailureCause.INPUT_READ_FAILURE)); + LOG.error("{} Execution Failed (Recoverable: input read failure)! Exception: {}", taskId, e); + return false; } - - } catch (final NoSuchElementException e) { - // The current data fetcher is still pending.. try next data fetcher - } catch (final IOException e) { - // IOException means that this task should be retried. - taskStateManager.onTaskStateChanged(TaskState.State.SHOULD_RETRY, - Optional.empty(), Optional.of(TaskState.RecoverableTaskFailureCause.INPUT_READ_FAILURE)); - LOG.error("{} Execution Failed (Recoverable: input read failure)! Exception: {}", taskId, e); - return false; } } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services