IntersectMBO / IntersectMBO/cardano-node

Logging threads are not killed when node dies

Open
#4,360 10 comments 0 reactions 2 assignees Claimed by @mgmeier View on GitHub
comp: benchmark Stale type: bug user type: internal
Dominant language
Haskell
Stars
3.2k
Forks
754
Avg merge
4d 20h
Merged PRs (30d)
20

Description

The following two threads are not shutdown when the node dies:

* ['startResourceTracer'](https://github.com/input-output-hk/cardano-node/blob/master/cardano-node/src/Cardano/Node/Tracing/Tracers/Resources.hs?plain=1#L20-L21)
* ['startPeerTracer'](https://github.com/input-output-hk/cardano-node/blob/master/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs#L47-L48)

Note that `link` only makes sure that if the created thread fails the main thread will receive an async exception, but it does not the other way around. Instead using `async` and `link` combination, one should use `withAsync` and write both function using the `with...` pattern:

```haskell
withResourceTracer :: Tracer IO RessourceStats
-> Int
-> (Async a -> IO ())
-> IO ()
withResournceTracer tr delayMilliseconds k = do
withAsync resourceThread k
where
...
```

The caller (e.g. the conitnuation `k`) ought to be responsible for makeing sure that the started thread fails the main thread will terminate. This is usually done with something like `wait`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.