**Apache Airflow version**: 2.1.0

**What happened**:

We use a python script that reads JSON configs from db to dynamically generate DAGs. Sometimes, when JSON Configs is updated, we expect DAGs to be removed in Airflow.  This doesn't always happen. From my observation, one of the following happens:
1) DAG is removed because the python script no longer generates it.
2) DAG still exists but run history is empty. When trigger the DAG, first task is stuck in `queued` status indefinitely.

**What you expected to happen**:
I expect the right behavior should be 
>1) DAG is removed because the python script no longer generates it.

**How to reproduce it**:
* Create a python script in DAG folder that dynamically generates multiple DAGs
* Execute these dynamically generated DAGs a few times
* Use Airflow Variable to toggle (reduce) the # of DAGs generated
* Examine if number of dynamically generated DAGs in the web UI


airflow/models/dag.py
if as_pk_tuple:
                condition = TI.filter_for_tis(TaskInstanceKey(*cols) for cols in tis.all())
                if condition is not None:
                    query = session.query(TI).filter(condition)
            if visited_external_tis is None:
                visited_external_tis = set()
            for ti in query.filter(TI.operator == ExternalTaskMarker.__name__):
                ti_key = ti.key.primary
                if ti_key in visited_external_tis:
                    continue
                visited_external_tis.add(ti_key)
                task: ExternalTaskMarker = cast(ExternalTaskMarker, copy.copy(self.get_task(ti.task_id)))
                ti.task = task
                if max_recursion_depth is None:
                    
                    
                    max_recursion_depth = task.recursion_depth
                if recursion_depth + 1 > max_recursion_depth:
                    
                    raise AirflowException(
                        "Maximum recursion depth {} reached for {} {}. "
                        "Attempted to clear too many tasks "
                        "or there may be a cyclic dependency.".format(
                            max_recursion_depth, ExternalTaskMarker.__name__, ti.task_id
                        )
                    )
                ti.render_templates()
                external_tis = (
                    session.query(TI)
                    .join(TI.dag_run)