[tune] Fault Tolerance: handle lost checkpoints by restart (#3657)

Checks that node failure with lost checkpoints does not crash. Also adds test.
This commit is contained in:
Richard Liaw
2019-01-04 22:05:27 -08:00
committed by GitHub
parent 7db1f3be2a
commit 960a943503
3 changed files with 99 additions and 55 deletions
+12 -3
View File
@@ -61,11 +61,17 @@ class RayTrialExecutor(TrialExecutor):
self._running[remote] = trial
def _start_trial(self, trial, checkpoint=None):
"""Starts trial and restores last result if trial was paused.
Raises:
ValueError if restoring from checkpoint fails.
"""
prior_status = trial.status
self.set_status(trial, Trial.RUNNING)
trial.runner = self._setup_runner(trial)
if not self.restore(trial, checkpoint):
return
if trial.status == Trial.ERROR:
raise RuntimeError("Restore from checkpoint failed.")
previous_run = self._find_item(self._paused, trial)
if (prior_status == Trial.PAUSED and previous_run):
@@ -127,12 +133,15 @@ class RayTrialExecutor(TrialExecutor):
try:
self._start_trial(trial, checkpoint)
except Exception:
logger.exception("Error stopping runner - retrying...")
logger.exception("Error starting runner. "
"Trying again without checkpoint.")
error_msg = traceback.format_exc()
time.sleep(2)
self._stop_trial(trial, error=True, error_msg=error_msg)
try:
self._start_trial(trial, checkpoint)
# This forces the trial to not start from checkpoint.
trial.clear_checkpoint()
self._start_trial(trial)
except Exception:
logger.exception("Error starting runner, aborting!")
error_msg = traceback.format_exc()