loopd: shutdown hangs when lnd goes away

Aperta
#1,309 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
Mezza giornata
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start in loopd/daemon.go: the internalErrChan buffer size where it is created, the swap client send near line 854, the static address loop-in manager send near line 1048, and Daemon.stop near line 1164. Reproduce by stopping and restarting lnd under a running loopd and watching for the hang after 'Runtime error in daemon, shutting down'. Done when shutdown completes, the macaroon db is released, and a new loopd can start.

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

Descrizione

When lnd stops or restarts under a running loopd, the daemon starts to shut down and then hangs. The process stays alive, the RPC port is closed, and the macaroon database stays locked, so a new loopd fails with "unable to open macaroon db: timeout".

Cause

internalErrChan has room for four errors (make(chan error, 4) in loopd/daemon.go) and is read once. After that read the daemon calls stop(), which waits for the wait group. When lnd goes away, more goroutines report an error than the channel can hold. The rest block on the send, inside goroutines the wait group is waiting for.

The comment at the swap client's send says "We don't have to worry about blocking as the internal error channel is sufficiently buffered", which no longer holds with the number of managers that now send to it.

Goroutine dump from a hung daemon on master (b41a3a32):

goroutine 114 [chan send]:            loopd/daemon.go:854   (swap client)
goroutine 218 [chan send]:            loopd/daemon.go:1048  (static address loop-in manager)
goroutine 364 [sync.WaitGroup.Wait]:  loopd/daemon.go:1164  (*Daemon).stop
Steps
  1. Run loopd against lnd on regtest, with experimental features on.
  2. Restart lnd.
  3. loopd logs "Runtime error in daemon, shutting down" and never logs "Daemon exited".

Reproduced three times in three tries.

Possible fix

Send to internalErrChan without blocking (a select with d.quit, or a default case), or keep draining the channel while stop() runs.

Lingua principale
Go
Stelle
593
Fork
139
Merge medio
2g 8h
PR unite (30g)
21

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 lightninglabs/loop

Tutte le issue di lightninglabs/loop

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.