Fix SessionManager database leak

All database access should be wrapped in with_connection blocks.

Much of this commit is whitespace.  It may help to view it with
--ignore-all-space or the w=0 parameter on GitHub.

[Story #55586616]
Fix a few database leaks

All database access should be wrapped in with_connection blocks.

To avoid breaking git blame with a bunch of whitespace, I outdented
the with_connection blocks as seems to be common in db.rb.

[Story #55586616]
Merge pull request #2271 from bturner-r7/bug/db-leaks

Land #2271, Fix database connection leaks