https://github.com/apache/airflow/blob/main/airflow/cli/commands/task_command.py#L145
*, task_instance: TaskInstance | TaskInstancePydantic, session: Session, lock_for_update: bool = False
) -> None:
    """
    Refreshes the task instance from the database based on the primary key.
    :param task_instance: the task instance
    :param session: SQLAlchemy ORM Session
    :param lock_for_update: if True, indicates that the database should
        lock the TaskInstance (issuing a FOR UPDATE clause) until the
        session is committed.
    :meta private:
    """
    if task_instance in session:
        session.refresh(task_instance, TaskInstance.__mapper__.column_attrs.keys())
    ti = TaskInstance.get_task_instance(
        dag_id=task_instance.dag_id,
        task_id=task_instance.task_id,
        run_id=task_instance.run_id,
        map_index=task_instance.map_index,
        select_columns=True,
        lock_for_update=lock_for_update,
        session=session,