MergePipeline deadlocks on graceful shutdown if a merge actor fails before or during shutdown

Aperta
#7,063 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Read quickwit/quickwit-indexing/src/actors/merge_pipeline.rs, focusing on perform_health_check and the handlers for FinishPendingMergesAndShutdownPipeline and Spawn. Trace the shutdown and retry paths described in the issue, then inspect nearby tests for merge pipeline supervision. Done means each listed interleaving exits the actor cleanly while the shutdown request still receives a successful reply.

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

Descrizione

bug
Description

MergePipeline can hang indefinitely after receiving FinishPendingMergesAndShutdownPipeline when a child actor fails (e.g., transient object-storage or metastore error) either right before or during graceful shutdown.

Root Cause

In quickwit/quickwit-indexing/src/actors/merge_pipeline.rs:

  1. perform_health_check (lines 404–428):
    • When self.handles_opt is None, it returns Ok(()) even if self.shutdown_initiated is true.
    • When Health::FailureOrUnhealthy occurs, it calls self.terminate().await (setting self.handles_opt = None) and schedules Spawn { retry_count: 0 }, even if self.shutdown_initiated is true.
  2. Handler<FinishPendingMergesAndShutdownPipeline> (lines 480–515):
    • Sets self.shutdown_initiated = true. If self.handles_opt is currently None (e.g., the pipeline just terminated after a failure and is waiting for Spawn backoff, or initial spawn failed and is retrying), it takes the else branch and returns Ok(()).
  3. Handler<Spawn> (lines 519–529):
    • Sees if self.shutdown_initiated { return Ok(()); } instead of exiting the actor.

Once self.shutdown_initiated == true and self.handles_opt.is_none(), SuperviseLoop continues ticking every second forever and MergePipeline never terminates (blocking graceful shutdown / decommission until an external timeout kills it).

Triggering Interleavings
  1. Failure during shutdown: FinishPendingMergesAndShutdownPipeline sets shutdown_initiated = true -> a merge actor (e.g., MergeSplitDownloader, Uploader, Publisher) fails on a transient storage/metastore error -> perform_health_check terminates actors (handles_opt = None) and schedules Spawn -> Spawn returns Ok(()) -> SuperviseLoop loops forever.
  2. Shutdown during failure backoff: A merge actor fails -> perform_health_check calls self.terminate().await (handles_opt = None) and schedules Spawn after HEARTBEAT -> FinishPendingMergesAndShutdownPipeline arrives before Spawn, sees handles_opt = None, returns Ok(()) -> Spawn returns Ok(()) -> SuperviseLoop loops forever.
  3. Shutdown during initial spawn retry: spawn_pipeline() fails on a transient metastore error (handles_opt = None) and schedules retry Spawn -> FinishPendingMergesAndShutdownPipeline arrives -> SuperviseLoop loops forever.
Suggested Fix

In quickwit/quickwit-indexing/src/actors/merge_pipeline.rs:

  • In perform_health_check:
    • If self.handles_opt is None and self.shutdown_initiated is true, return Err(ActorExitStatus::Success).
    • On Health::FailureOrUnhealthy, after self.terminate().await, if self.shutdown_initiated is true, return Err(ActorExitStatus::Success) instead of scheduling Spawn.
  • In Handler<Spawn>:
    • If self.shutdown_initiated is true, return Err(ActorExitStatus::Success).

(Keeping Handler<FinishPendingMergesAndShutdownPipeline> returning Ok(()) preserves clean ask(FinishPendingMergesAndShutdownPipeline) replies for callers, while the next SuperviseLoop / Spawn tick exits cleanly with ActorExitStatus::Success.)

Lingua principale
Rust
Stelle
11.8k
Fork
628
Merge medio
2g 22h
PR unite (30g)
50

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 quickwit-oss/quickwit

Tutte le issue di quickwit-oss/quickwit

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.