Job cancellation doesn't work in database/sql driver
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- Go
- Stelle
- 5.7k
- Fork
- 179
- Merge medio
- 2g 19h
- PR unite (30g)
- 12
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di riverqueue/river
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
riverqueue/river#1358 · 1 commento ·
-
River job stuck at running Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
riverqueue/river#1258 · 7 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
riverqueue/river#1225 · 14 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1185 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
riverqueue/river#1183 · 2 reazioni ·
Tutte le issue di riverqueue/river
Issue simili
-
nix: vendorHash is outdated Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Bob Shell support Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
santhosh-tekuri/jsonschema#276 ·