Change create_record to get_or_create_record. For now, this requires disabling transactions and might not be completely reliable.