https://github.com/apache/airflow/pull/14531/checks?check_run_id=2106170690#step:6:10298

Looks like it is connected with #14772 

```
____________ TestSchedulerJob.test_verify_integrity_if_dag_changed _____________
  
  self = <tests.jobs.test_scheduler_job.TestSchedulerJob testMethod=test_verify_integrity_if_dag_changed>
  
      def test_verify_integrity_if_dag_changed(self):
          # CleanUp
          with create_session() as session:
              session.query(SerializedDagModel).filter(
                  SerializedDagModel.dag_id == 'test_verify_integrity_if_dag_changed'
              ).delete(synchronize_session=False)
      
          dag = DAG(dag_id='test_verify_integrity_if_dag_changed', start_date=DEFAULT_DATE)
          BashOperator(task_id='dummy', dag=dag, owner='airflow', bash_command='echo hi')
      
          scheduler = SchedulerJob(subdir=os.devnull)
          scheduler.dagbag.bag_dag(dag, root_dag=dag)
          scheduler.dagbag.sync_to_db()
      
          session = settings.Session()
          orm_dag = session.query(DagModel).get(dag.dag_id)
          assert orm_dag is not None
      
          scheduler = SchedulerJob(subdir=os.devnull)
          scheduler.processor_agent = mock.MagicMock()
          dag = scheduler.dagbag.get_dag('test_verify_integrity_if_dag_changed', session=session)
          scheduler._create_dag_runs([orm_dag], session)
      
          drs = DagRun.find(dag_id=dag.dag_id, session=session)
          assert len(drs) == 1
          dr = drs[0]
      
          dag_version_1 = SerializedDagModel.get_latest_version_hash(dr.dag_id, session=session)
          assert dr.dag_hash == dag_version_1
          assert scheduler.dagbag.dags == {'test_verify_integrity_if_dag_changed': dag}
          assert len(scheduler.dagbag.dags.get("test_verify_integrity_if_dag_changed").tasks) == 1
      
          # Now let's say the DAG got updated (new task got added)
          BashOperator(task_id='bash_task_1', dag=dag, bash_command='echo hi')
  >       SerializedDagModel.write_dag(dag=dag)
  
  tests/jobs/test_scheduler_job.py:2827: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  airflow/utils/session.py:65: in wrapper
      return func(*args, session=session, **kwargs)
  /usr/local/lib/python3.6/contextlib.py:88: in __exit__
      next(self.gen)
  airflow/utils/session.py:32: in create_session
      session.commit()
  /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:1046: in commit
      self.transaction.commit()
  /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:504: in commit
      self._prepare_impl()
  /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:483: in _prepare_impl
                                  value_params,
                                  True,
                              )
      
              if check_rowcount:
                  if rows != len(records):
                      raise orm_exc.StaleDataError(
                          "UPDATE statement on table '%s' expected to "
                          "update %d row(s); %d were matched."
  >                       % (table.description, len(records), rows)
                      )
  E                   sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'serialized_dag' expected to update 1 row(s); 0 were matched.
  
  /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py:1028: StaleDataError
```


<!--

Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
Don't worry if they're not all applicable; just try to include what you can :-)

If you need to include code snippets or logs, please put them in fenced code
blocks.  If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>

Please delete these comment blocks before submitting the issue.

-->

<!--

IMPORTANT!!!

PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!

PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!

Please complete the next sections or the issue will be closed.
These questions are the first thing we need to know to understand the context.

-->

**Apache Airflow version**:


**Kubernetes version (if you are using kubernetes)** (use `kubectl version`):

**Environment**:

- **Cloud provider or hardware configuration**:
- **OS** (e.g. from /etc/os-release):
- **Kernel** (e.g. `uname -a`):
- **Install tools**:
- **Others**:

**What happened**:

<!-- (please include exact error messages if you can) -->

**What you expected to happen**:

<!-- What do you think went wrong? -->

**How to reproduce it**:
<!---

As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.

If you are using kubernetes, please attempt to recreate the issue using minikube or kind.

## Install minikube/kind

- Minikube https://minikube.sigs.k8s.io/docs/start/
- Kind https://kind.sigs.k8s.io/docs/user/quick-start/

If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action

You can include images using the .md style of
![alt text](http://url/to/img.png)

To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.

--->


**Anything else we need to know**:

<!--

How often does this problem occur? Once? Every time etc?

Any relevant logs to include? Put them here in side a detail tag:
<details><summary>x.log</summary> lots of stuff </details>

-->

tests/jobs/test_scheduler_job.py
state=State.FAILED,
            execution_date=DEFAULT_DATE + timedelta(days=1),
            start_date=DEFAULT_DATE + timedelta(days=1),
            session=session,
        )
        ti = dr.get_task_instance(task_id=op1.task_id, session=session)
        ti.state = initial_task_state
        session.commit()
        
        
        scheduler = SchedulerJob(num_runs=2, processor_poll_interval=30)
        scheduler.dagbag = dagbag
        executor = MockExecutor(do_update=False)
        executor.queued_tasks
        scheduler.executor = executor
        processor = mock.MagicMock()
        processor.done = False
        scheduler.processor_agent = processor
        with mock.patch.object(settings, "USE_JOB_SCHEDULE", False), conf_vars(
            {('scheduler', 'clean_tis_without_dagrun_interval'): '0.001'}
        ):
            scheduler._run_scheduler_loop()
        ti = dr.get_task_instance(task_id=op1.task_id, session=session)
        assert ti.state == expected_task_state
        assert ti.start_date is not None
        if expected_task_state in State.finished:
            assert ti.end_date is not None
            assert ti.start_date == ti.end_date
            assert ti.duration is not None
    def test_dagrun_timeout_verify_max_active_runs(self):