Job cancellation doesn't work in database/sql driver
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
调研方向
Reproduce the issue with the SortWorker example, riverui's Cancel action, and riverdatabasesql.New using the described pgx and ocsql setup. Start by tracing cancellation from the cancel_attempted_at metadata to the Work context; done means the worker observes ctx.Done, logs CANCELLED, and stops before the 20-second delay.
由索引模型根据 Issue 内容生成。
描述
Hi!
I am using the example SortWorker job with small adjustments to test longer-running jobs with cancellation but it does not seem to work.
const SortJobKind = "sort"
type SortArgs struct {
Strings []string `json:"strings"`
}
func (SortArgs) Kind() string {
return SortJobKind
}
type SortWorker struct {
river.WorkerDefaults[SortArgs]
}
func (w *SortWorker) Work(ctx context.Context, job *river.Job[SortArgs]) error {
log.Printf("STARTING: %d", job.ID)
select {
case <-ctx.Done():
log.Printf("CANCELLED: %d", job.ID)
return ctx.Err()
case <-time.After(20 * time.Second):
log.Printf("WILL DO: %d", job.ID)
}
items := job.Args.Strings
sort.Strings(items)
log.Printf("RESULT: %+v\n", items)
return nil
}
When the job appears in the User Interface (riverui), I click Cancel but the job keeps running. In the logs I eventually get from STARTING to WILL DO but never observe CANCELLED.
The only thing that indicates some attempt at cancellation is the metadata field on the job which states:
{
"cancel_attempted_at": "2024-10-02T....."
}
Am I doing something wrong or is there a potential bug?
I am running v0.12.1 and using riverdatabasesql.New, though the underlying connection is pgx, wrapped with opencensus tracing (ocsql).
- 主要语言
- Go
- 星标
- 5.7k
- 派生
- 179
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 12
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
riverqueue/river 的其他 Issue
-
难度 5/5 一周以上 新手友好度 45/100
riverqueue/river#1358 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
riverqueue/river#1258 · 7 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
riverqueue/river#1225 · 14 条评论 ·
-
难度 4/5 3-5 天 新手友好度 52/100
riverqueue/river#1185 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 52/100
riverqueue/river#1183 · 2 个 reaction ·
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
santhosh-tekuri/jsonschema#276 ·