Fix the various database stalls/locks for SQLite backend