Repository navigation
fix(runner): distinguish lease loss from a database failure - #937
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
Yanami-2K
approved these changes
Nov 16, 2026
Yanami-2K
left a comment
Collaborator
There was a problem hiding this comment.
核对了 internal/repo/runners.go:takeRunnerTaskForLease 现在只在 gorm.ErrRecordNotFound 时返回 ErrRunnerTaskLeaseLost,其他数据库错误原样返回,StartRunnerTask / RenewRunnerTaskLease / CompleteRunnerTask 三个调用点都同步改了。这样续租遇到瞬时数据库故障时不会被误判为丢失租约而取消任务。测试通过 gorm 回调注入读失败,用 errors.Is 断言三个操作返回的是原始错误,并验证错误的 owner 仍报丢失租约、恢复后原 owner 能续租,断言是充分的。它和 #945(runner 对 5xx 的完成上报做重试)配合使用效果更好。本 PR 只跑了开源扫描,合入前请触发 platform CI。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A failed database read while verifying a runner task lease is currently reported as lost ownership. On renewal the runner treats that result as final and cancels the task, even if it still holds its lease and the next database read would succeed.
Report lease loss when a successful lookup finds no matching row. Preserve database errors so the existing server-error handling and runner renewal retry behavior can apply.
Validation
Fault injection reproduced false lease-loss errors for start, renew and complete. The corrected paths return the database error, still reject the wrong owner, and allow recovery of the original lease. The full repo package passed under UTC, along with the public-content check and diff check. MySQL and live execution-machine tests were not run.