diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index b1f6f4ca123c..a8747f62bddd 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1694,7 +1694,7 @@ def set_state(self, state: JobState) -> bool: # generate statement that will not revert DELETING or DELETED back to anything non-terminal rval = session.execute( update(Job.table) - .where(Job.id == self.id, ~Job.state.in_((Job.states.DELETING, Job.states.DELETED))) + .where(Job.id == self.id, ~Job.state.in_((state, *Job.finished_states))) .values(state=state) ) if rval.rowcount == 1: