fix a search thread race condition