Fix postgresql connection leaks on error
Merge pull request #1709 from strk/2.1.x-out_of_pool_slots

Fix postgresql connection leaks on error