A failed activity lock renewal can lose the activity result; the orchestration waits forever
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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
- スター
- 226
- フォーク
- 62
- 平均マージ
- 20時間 46分
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/duroxide のほかの issue
-
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 日以内に返信
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
microsoft/duroxide の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
fritzprix/libr-agent#2165 ·
メンテナーはふだん 1 日以内に返信
-
area:ecosystem bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Chelis-Lang/chelis#3942 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
review-bot
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信