@@ -366,17 +366,20 @@ pub async fn cancel(pool: &PgPool, id: Uuid) -> Result<Option<Evaluation>> {
366366}
367367
368368/// Requeue a cancelled, failed, or timed-out evaluation after discarding its
369- /// stale builds. One-shot jobsets are re-enabled for the new attempt.
369+ /// stale builds. A disabled jobset rejects the restart; a retained one-shot
370+ /// jobset is re-enabled for its new attempt.
370371///
371372/// # Errors
372373///
373374/// Returns an error if the database transaction fails.
374375pub async fn restart ( pool : & PgPool , id : Uuid ) -> Result < Option < Evaluation > > {
375376 let mut tx = pool. begin ( ) . await ?;
376377 let evaluation = sqlx:: query_as :: < _ , Evaluation > (
377- "UPDATE evaluations SET status = 'pending', evaluation_time = NOW(), \
378- error_message = NULL, inputs_hash = NULL WHERE id = $1 AND status IN \
379- ('cancelled', 'failed', 'timed_out') RETURNING *",
378+ "UPDATE evaluations e SET status = 'pending', evaluation_time = NOW(), \
379+ error_message = NULL, inputs_hash = NULL FROM jobsets j WHERE e.id = $1 \
380+ AND e.jobset_id = j.id AND e.status IN ('cancelled', 'failed', \
381+ 'timed_out') AND (j.state = 'one_shot' OR (j.enabled AND j.state IN \
382+ ('enabled', 'one_at_a_time'))) RETURNING e.*",
380383 )
381384 . bind ( id)
382385 . fetch_optional ( & mut * tx)
0 commit comments