Per plugin DB sessions

Since we have multiple threads accessing the database, we have had quite a few problems with database errors. I believe this was stemming from having one long running transaction open on the database that lasted the length of a task run. When other threads needed the db during task execution, they could fail due to the database being locked.

This branch makes changes so that each plugin method gets its own database session (and thus transaction) which should significantly reduce the time transactions are open, and prevent many of the locking issues encountered.

All of the tests are passing, but there may still be plugins that were relying on the task session being rolled back on a task abort that still need to be tweaked.

If anyone having database lock issues regularly could test this branch it would be much appreciated.