Allow connection_handler to be overriden per-thread

This PR is in response to #8344, it introduces the ability to set a new connection_handler per thread while maintaining the current behavior. 

This can be used by applications that need multiple concurrent connections to different dbs. 

A typical use case may be for apps that serve multiple subdomains from a single rails app and need db isolation per subdomain.

cc @tenderlove