Avoid nested lock in DBThread

Signed-off-by: Paul Brook <paul@nowt.org>