fix a deadlock problem on db failure