Catch mongo duplicate key errors and retry