added retries if database is locked