Try to avoid exceptions by forcing incoming requests to wait if the db is already open.

Try not to keep the db open for long periods - broke up the refresh into phases that won't be doing networking with the db locked.