Description
During shutdown, the database connection is closed before all background goroutines have finished their work. As a result, in-flight operations continue to use the DB and fail with errors like:
time="2026-04-23T11:57:47+02:00" level=error msg="failed to process commitment tx" error="sql: database is closed"
This indicates a race condition between DB shutdown and ongoing async processing (e.g. commitment tx handling).
Expected behavior
All goroutines that depend on the DB should gracefully finish (or be canceled) before the database is closed.
Description
During shutdown, the database connection is closed before all background goroutines have finished their work. As a result, in-flight operations continue to use the DB and fail with errors like:
time="2026-04-23T11:57:47+02:00" level=error msg="failed to process commitment tx" error="sql: database is closed"
This indicates a race condition between DB shutdown and ongoing async processing (e.g. commitment tx handling).
Expected behavior
All goroutines that depend on the DB should gracefully finish (or be canceled) before the database is closed.