def METHOD_NAME(pid, user_id: int):
    """
    Set user_id as a new owner for the record (given the record pid)
    :params     pid : record pid
                user_id : id of the user to add as a owner
    """
    record = pid2record(pid)
    if user_id in record['_deposit']['owners']:
        current_app.logger.warning(
            "OWN-API: User is already an owner of the record, skipping..", exc_info=True)
        current_app.logger.warning("OWN-API: Owners are {}".format(" ".join([str(User.query.filter(
            User.id.in_([i])).all()[0]) for i in record['_deposit']['owners']])), exc_info=True)
        abort(400, description="User is already an owner of the record.")
    current_app.logger.info("OWN-API: User {} is an owner. Changing the ownership ...".format(str(User.query.filter(
        User.id.in_([user_id])).all()[0].email)))
    record['_deposit']['owners'].append(user_id)
    current_app.logger.info("OWN-API: Updated users: {}".format("\n".join([str(User.query.filter(
        User.id.in_([i])).all()[0].email) for i in record['_deposit']['owners']])))
    with current_app.test_request_context('/', base_url=get_base_url()):
        record.commit()
        db.session.commit()