Skip to content

Running out of OS threads in a server

I have a web server that uses my mysql-simple package, and it dies after serving several hundred requests.

The mysql-simple package is a wrapper around the MySQL C API, which is unfortunately not signal-safe. GHC RTS signals kill it, so I've been using runInBoundThread to manage the signals from the Haskell world.

Unfortunately, the number of OS threads in flight increases with every use of runInBoundThread, so after a few hundred requests, I run out of OS threads (the default limit being 1024 threads on Linux), and my process is killed.

Trac metadata
Trac field Value
Version 6.12.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information