Fix misattributed queries on multithreaded servers

The controller for the current request is stored in a class instance variable right now. This variable is shared between threads, so in a multithreaded environment queries are attributed to whichever request started most recently.

This patch stores the controller in a thread-local variable instead, so parallel requests in the same process can't interfere with each other.