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

Abierto
#7,063 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.)

Lenguaje dominante
Rust
Estrellas
11.8k
Forks
628
Merge medio
2 d 22 h
PR fusionados (30 d)
50

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quickwit-oss/quickwit

Todos los issues de quickwit-oss/quickwit

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.