B:BD[
3.26572] → [
2.142:212]
                    createBuildStep(txn, 0, build, r, "", bssFailed);
                    /* Find the previous build step record, first by
                       derivation path, then by output path. */
                    BuildID propagatedFrom = 0;
                    auto res = txn.parameterized
                        ("select max(build) from BuildSteps where drvPath = $1 and startTime != 0 and stopTime != 0 and status = 1")
                        (r->drvPath).exec();
                    if (!res[0][0].is_null()) propagatedFrom = res[0][0].as<BuildID>();
                    if (!propagatedFrom) {
                        for (auto & output : r->drv.outputs) {
                            auto res = txn.parameterized
                                ("select max(s.build) from BuildSteps s join BuildStepOutputs o on s.build = o.build where path = $1 and startTime != 0 and stopTime != 0 and status = 1")
                                (output.second.path).exec();
                            if (!res[0][0].is_null()) {
                                propagatedFrom = res[0][0].as<BuildID>();
                                break;
                            }
                        }
                    }
                    createBuildStep(txn, 0, build, r, "", bssCachedFailure, "", propagatedFrom);