Increase the default threadpool size to twice the cores or at least
eight.

Add a counter of threads used by sql commands. This is because sql
commands can create database locks that "live" across many commands
and it is possible to deadlock while waiting on a db lock and no
threads available in the pool to unlock. If you reach this limit,
the only option is to terminate the connection. (The better thing
to do would be not to ever block in threads, but for now this will
suffice).