Fixed db race condition.