Make DB (truly) threadsafe