mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-27 13:40:37 +00:00
update_status guarded expected_lease_owner (and the protect_terminal backfill) on a plain session.get. On SQLite a concurrent requeue plus re-claim can commit between that read and this session's write, so the stale guard passed and the late write clobbered the fresh claim — clearing the new owner's lease fencing and overwriting its status. The guard now re-reads under the parent's writer lock (the same task -> run lock order as fail_launching_run / expire_queued_runs), with populate_existing so the identity map does not serve the pre-lock row back untouched. This is the run-row counterpart of the staleness #5777 fixed for the task-level lease release. Red/green: tests/test_scheduled_task_dispatch_race.py gains a parking session proxy that commits a requeue + re-claim by another scheduler between update_status's read and its write — on main the late write returned True and clobbered the claim; with the change it is fenced (False) and the re-claim survives. Signed-off-by: yetuge <2219677952@qq.com>