Don't leave postgres transactions open on errors

I'm not sure where we weren't rolling back, but it was causing significant performance degradation.  This is just a catchall to protect the system from this kind of resource leak.