loopd: shutdown hangs when lnd goes away

Đang mở
#1,309 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Go
Star
593
Fork
139
Merge trung bình
2 ngày 8 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lightninglabs/loop

Tất cả issue của lightninglabs/loop

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.