Use reentrant lock on database to avoid issue.