From a45e43813a98a42ffe5083d3113f1f947167232d Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Tue, 31 Jan 2023 00:22:48 +1300 Subject: [PATCH] Fix restart after adding new deps to spawned task. --- cylc/flow/data_store_mgr.py | 7 ++++++- cylc/flow/task_pool.py | 15 +++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cylc/flow/data_store_mgr.py b/cylc/flow/data_store_mgr.py index 819f9f1d41f..9390e8d13c4 100644 --- a/cylc/flow/data_store_mgr.py +++ b/cylc/flow/data_store_mgr.py @@ -1194,7 +1194,12 @@ def apply_task_proxy_db_history(self): self.db_load_task_proxies[ikey][0].state.prerequisites ): for key in itask_prereq.satisfied.keys(): - itask_prereq.satisfied[key] = prereqs[key] + try: + itask_prereq.satisfied[key] = prereqs[key] + except KeyError: + # This prereq is not in the DB: new dependencies + # added to an already-spawned task before restart. + itask_prereq.satisfied[key] = False # Extract info from itasks to data-store. for task_info in self.db_load_task_proxies.values(): diff --git a/cylc/flow/task_pool.py b/cylc/flow/task_pool.py index 700727ba892..1b74681317f 100644 --- a/cylc/flow/task_pool.py +++ b/cylc/flow/task_pool.py @@ -500,12 +500,19 @@ def load_db_task_pool_for_restart(self, row_idx, row): flow_nums, ) ): - key = (prereq_cycle, prereq_name, prereq_output) - sat[key] = satisfied if satisfied != '0' else False + # Prereq satisfaction as recorded in the DB. + sat[ + (prereq_cycle, prereq_name, prereq_output) + ] = satisfied if satisfied != '0' else False for itask_prereq in itask.state.prerequisites: - for key, _ in itask_prereq.satisfied.items(): - itask_prereq.satisfied[key] = sat[key] + for key in itask_prereq.satisfied.keys(): + try: + itask_prereq.satisfied[key] = sat[key] + except KeyError: + # This prereq is not in the DB: new dependencies + # added to an already-spawned task before restart. + itask_prereq.satisfied[key] = False if itask.state_reset(status, is_runahead=True): self.data_store_mgr.delta_task_runahead(itask)