A failed activity lock renewal can lose the activity result; the orchestration waits forever

未关闭
#56 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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 内容生成。

描述

bug

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

How it fails

  1. An activity runs. Its lock is valid.
  2. One renew_work_item_lock call returns an error. The lock is still valid.
  3. The activity manager calls cancellation_token.cancel() and stops renewing.
  4. The dispatcher takes the cancellation branch. It waits up to activity_cancellation_grace_period for the activity to return.
  5. The dispatcher calls ack_work_item(token, None). None means "delete the work item and queue nothing".
  6. The lock is still valid, so the provider deletes the row. No ActivityCompleted and no ActivityFailed is queued.
  7. The orchestration never gets a result for this activity. It stays Running forever, 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.

  1. Runtime with worker_lock_timeout = 6 s. The lock is renewed every 3 s.
  2. Start an orchestration that awaits one activity. The activity loops and returns as soon as is_cancelled() is true.
  3. After 1 s, rename the SQL function renew_work_item_lock for 3.5 s, then rename it back. One renewal fails while the lock stays valid.
  4. Wait 9 s.

Result:

  • The orchestration status is still Running.
  • worker_queue has 0 rows and orchestrator_queue has 0 rows.
  • The history has ActivityScheduled and 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

Tracked in #55.

主要语言
Rust
星标
235
派生
63
平均合并
2 天 1 小时
30 天内合并 PR
7

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/duroxide 的其他 Issue

查看 microsoft/duroxide 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。