Skip to content

Commit f262b7f

Browse files
committed
Sch: Fix task error-related assertion
1 parent 364bb6f commit f262b7f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Diff for: src/sch/Sch.jl

+16-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,22 @@ function schedule!(ctx, state, procs=procs_to_use(ctx))
610610
end
611611
task = pop!(state.ready)
612612
timespan_start(ctx, :schedule, task.id, (;thunk_id=task.id))
613-
@assert !haskey(state.cache, task)
613+
if haskey(state.cache, task)
614+
if haskey(state.errored, task)
615+
# An error was eagerly propagated to this task
616+
finish_failed!(state, task)
617+
else
618+
# This shouldn't have happened
619+
iob = IOBuffer()
620+
println(iob, "Scheduling inconsistency: Task being scheduled is already cached!")
621+
println(iob, " Task: $(task.id)")
622+
println(iob, " Cache Entry: $(typeof(state.cache[task]))")
623+
ex = SchedulingException(String(take!(iob)))
624+
state.cache[task] = ex
625+
state.errored[task] = true
626+
end
627+
@goto pop_task
628+
end
614629
opts = merge(ctx.options, task.options)
615630
sig = signature(task, state)
616631

Diff for: src/sch/util.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,17 @@ function set_failed!(state, origin, thunk=origin)
145145
filter!(x->x!==thunk, state.ready)
146146
state.cache[thunk] = ThunkFailedException(thunk, origin, state.cache[origin])
147147
state.errored[thunk] = true
148+
finish_failed!(state, thunk, origin)
149+
end
150+
function finish_failed!(state, thunk, origin=nothing)
148151
fill_registered_futures!(state, thunk, true)
149152
if haskey(state.waiting_data, thunk)
150153
for dep in state.waiting_data[thunk]
151154
haskey(state.waiting, dep) &&
152155
delete!(state.waiting, dep)
153156
haskey(state.errored, dep) &&
154157
continue
155-
set_failed!(state, origin, dep)
158+
origin !== nothing && set_failed!(state, origin, dep)
156159
end
157160
delete!(state.waiting_data, thunk)
158161
end

0 commit comments

Comments
 (0)