SPARK-4454 Fix race condition in DAGScheduler

Simple fix to race condition

Hm, is this actually thread-safe either? It's not a concurrent `Map`. Even if it is, I'm not clear that it stops many values for being cached and computed for an ID, but if that's cheap and they're immutable, that could be fine.