sanely handle duplicate contacts in db

Surfaced in #1442