Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Job cancellation doesn't work in database/sql driver

オープン
#630 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
go, postgresql
領域
backend, database

調査の方向性

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時間
マージ済み PR(30日)
12

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

riverqueue/river のほかの issue

riverqueue/river の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。