amrishlal commented on a change in pull request #7174: URL: https://github.com/apache/pinot/pull/7174#discussion_r687923127
########## File path: pinot-core/src/main/java/org/apache/pinot/core/periodictask/BasePeriodicTask.java ########## @@ -111,22 +126,49 @@ protected void setUpTask() { */ @Override public final void run() { - _running = true; + try { + // Don't allow a task to run more than once at a time. + _runLock.lock(); + _running = true; - if (_started) { - long startTime = System.currentTimeMillis(); - LOGGER.info("Start running task: {}", _taskName); - try { - runTask(); - } catch (Exception e) { - LOGGER.error("Caught exception while running task: {}", _taskName, e); + if (_started) { + long startTime = System.currentTimeMillis(); + LOGGER.info("Start running task: {}", _taskName); + try { + runTask(); + } catch (Exception e) { + LOGGER.error("Caught exception while running task: {}", _taskName, e); + } + LOGGER.info("Finish running task: {} in {}ms", _taskName, System.currentTimeMillis() - startTime); + } else { + LOGGER.warn("Task: {} is skipped because it is not started or already stopped", _taskName); } - LOGGER.info("Finish running task: {} in {}ms", _taskName, System.currentTimeMillis() - startTime); - } else { - LOGGER.warn("Task: {} is skipped because it is not started or already stopped", _taskName); + + _running = false; + } finally { + _runLock.unlock(); + _running = false; } + } - _running = false; + @Override + public void run(@Nullable java.util.Properties periodicTaskProperties) { + Properties savedPeriodicTaskProperties = _activePeriodicTaskProperties; Review comment: This seems to be OK, because if `savedPeriodicTaskProperties` is initialized to `null` by default, then `_activePeriodicTaskProperties` might be modified to `null` instead of its original value in `finally` block if there is an exception in the try block before savedPeriodicTaskProperties is initialized. -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org