A failed activity lock renewal can lose the activity result; the orchestration waits forever
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- rust
调研方向
Read the renewal-error branch in src/runtime/dispatchers/worker.rs and the cancellation branch of run_activity_with_cancellation there. The issue says distinguishing a lost lock from retryable provider errors and avoiding deletion while the lock may still be valid are relevant; inspect provider error handling before assessing the scope. Done means a transient renewal failure does not lose the activity result, and the orchestration receives its completion or failure.
由索引模型根据 Issue 内容生成。
描述
Summary
One failed call to renew_work_item_lock can lose an activity result for good. The orchestration that scheduled the activity then waits forever.
The activity manager treats every renewal error as "the lock was stolen". It does this also for an error that goes away, such as a dropped connection or a pool timeout, while the lock is still valid.
Where
spawn_activity_manager, the renewal error branch: https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/runtime/dispatchers/worker.rs#L841-L851run_activity_with_cancellation, the cancellation branch: https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/runtime/dispatchers/worker.rs#L558-L604
How it fails
- An activity runs. Its lock is valid.
- One
renew_work_item_lockcall returns an error. The lock is still valid. - The activity manager calls
cancellation_token.cancel()and stops renewing. - The dispatcher takes the cancellation branch. It waits up to
activity_cancellation_grace_periodfor the activity to return. - The dispatcher calls
ack_work_item(token, None).Nonemeans "delete the work item and queue nothing". - The lock is still valid, so the provider deletes the row. No
ActivityCompletedand noActivityFailedis queued. - The orchestration never gets a result for this activity. It stays
Runningforever, unless its own code has a timeout.
The window is the time between the failed renewal and the lock expiry. With the defaults (30 s lock, renewal 5 s before the end) it is 5 s. An activity that checks for cancellation returns well inside that window. So the well-behaved activities are the ones that lose their result.
If the activity returns after the lock expired, the ack fails, the row stays, and another worker runs the activity again. That case is fine.
Reproduction
Reproduced on PostgreSQL with duroxide 0.1.30 and duroxide-pg 0.1.35, through the Node.js SDK.
- Runtime with
worker_lock_timeout= 6 s. The lock is renewed every 3 s. - Start an orchestration that awaits one activity. The activity loops and returns as soon as
is_cancelled()is true. - After 1 s, rename the SQL function
renew_work_item_lockfor 3.5 s, then rename it back. One renewal fails while the lock stays valid. - Wait 9 s.
Result:
- The orchestration status is still
Running. worker_queuehas 0 rows andorchestrator_queuehas 0 rows.- The history has
ActivityScheduledand no completion event.
Suggested fix
- In the activity manager, cancel only when the provider reports that the lock is gone. Retry other errors, at least until the lock would expire.
- That needs a way to tell "lock not found" from other failures. Today both arrive as a
ProviderError. An error kind for "lock lost" would do it. - In the cancellation branch, do not delete a work item whose lock can still be valid. Abandon it, so it is delivered again.
Related
- #41 and #42 cover a retryable error on
ack_work_itemin the same file. - The cancellation branch has a second, smaller problem. When the lock really was stolen (the normal case, for example an activity that lost a
select),ack_work_item(token, None)always fails, because the provider already removed the row. Every normally cancelled activity then logs two warnings ("Failed to ack cancelled activity work item" and "worker: atomic ack failed, abandoning work item") and callsrecord_activity_infra_error(): https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/runtime/dispatchers/worker.rs#L593-L603 and https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/runtime/dispatchers/worker.rs#L748-L762.
Tracked in #55.
- 主要语言
- Rust
- 星标
- 235
- 派生
- 63
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/duroxide 的其他 Issue
-
enhancement
难度 3/5 半天 新手友好度 70/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 38/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 74/100
维护者通常 1 天内回复
-
One failed session lock renewal loses the session: no retry, no log, no signal to running activities未关闭bug
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 72/100
维护者通常 1 天内回复
查看 microsoft/duroxide 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
test(hydro_std): track_membership join and leave are untested可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
hydro-project/hydro#3289 ·
维护者通常 1 天内回复
-
diagram-bug good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
bug security
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 4 天内回复