Query cancellation leaks tasks and loses metrics

Aperta
#481 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust

Direzione di ricerca

Start with the three sub-issues: #482 for task cleanup in beacon-db/beacon-file-formats/beacon-nd-array/src/arrow/morsel.rs, #483 for pruning in beacon-db/beacon-file-formats/beacon-arrow-atlas/src/datafusion/pruning.rs, and #484 for metrics in beacon-db/beacon-core/src/runtime.rs. Read the linked sub-issue for the chosen problem; #484 first needs a decision on how to represent partial metrics. Done means addressing that sub-issue’s cancellation behavior and validating it with its relevant tests.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug nd-pipeline rust

Describe the bug

A client cancels a query when it disconnects. The scan stops. Three problems remain.

Nothing wraps the query in a tokio::spawn. So cancellation depends on the drop of the handler future.


Problem 1. Dataset opens continue after cancellation. #482

Worker::prefetch starts each dataset open with tokio::spawn. The worker holds the JoinHandle.

This path has no Drop implementation. Tokio detaches a task when the code drops its handle. So up to target_partitions opens run to the end. Each one registers into a MorselSource that no worker reads.

File: beacon-db/beacon-file-formats/beacon-nd-array/src/arrow/morsel.rs


Problem 2. The pruning index build does not stop. #483

candidate_filter builds the index on tokio::task::spawn_blocking. Tokio cannot cancel a blocking task. The blocking pool runs it to the end.

A large collection commits real CPU time to a query that no client reads.

File: beacon-db/beacon-file-formats/beacon-arrow-atlas/src/datafusion/pruning.rs


Problem 3. A cancelled query records no metrics. #484

The stream output records metrics at stream end. A cancelled query never reaches that point. The query store then holds no row for it. The atlas_* counters are lost too.

A slow query that a client abandons leaves no trace. These queries need diagnosis the most.

File: beacon-db/beacon-core/src/runtime.rs


Expected behavior

  1. A cancelled query stops every task it started.
  2. A cancelled query records the metrics it collected.

More context

The two output routes cancel differently.

The stream output holds a lazy stream in the response body. A disconnect drops the body. The drop reaches the scan. The scan stops. This route works well.

The file output runs to the end inside run_query. It drains the whole COPY TO before the server sends any byte. No write fails in that time. So the server detects the disconnect late.

File: beacon-server/beacon-server/src/axum/client/query.rs


Suggested fix

Each problem has its own issue. See the sub-issue list above.

  • #482 aborts the open task on drop.
  • #483 stops the pruning index build.
  • #484 records the metrics of a cancelled query.

Items 1 and 2 are independent.

Item 3 needs a decision first. Mark the row as partial, or add a state column.


Scope

Problem 1 affects every nd format. netCDF, HDF5, Zarr and Atlas all read through MorselSource.

Problem 2 affects Atlas only.

Problem 3 affects every stream query.

Lingua principale
Rust
Stelle
16
Fork
4
Merge medio
19h 58m
PR unite (30g)
39

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di maris-development/beacon

Tutte le issue di maris-development/beacon

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.