kwkwc opened a new pull request #19536:
URL: https://github.com/apache/airflow/pull/19536
I use ``task_instance_mutation_hook`` in Airflow ``2.2.1`` to dynamically
assign ``queue``:
```python
def task_instance_mutation_hook(task_instance: TaskInstance):
from airflow.settings import Session
session = Session()
dag_run = task_instance.get_dagrun(session)
conf = dag_run.conf
if conf and conf.get('queue'):
task_instance.queue = conf.get('queue')
```
Doing so allows you to specify the queue normally.
This is my database data:

But when I click on ``Instance Details`` or ``Clear`` in the UI, the
``queue`` is restored to its ``default`` value.

This is the database data that was restored after I clicked on ``one's
Instance Details``:

I found that the problem is that both ``Instance Details`` and ``Clear``
call the ``refresh_from_task`` and the current ``queue`` is overwritten.
https://github.com/apache/airflow/blob/7622f5e08261afe5ab50a08a6ca0804af8c7c7fe/airflow/models/taskinstance.py#L763-L773
---
**^ Add meaningful description above**
Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
for more information.
In case of fundamental code change, Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]