<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.3.1 (latest released)</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">I have added a new task to an existsting workflow (DAG), where the other tasks already had previous runs.<br>
When I added the new task, the grid became inaccessible, because it wanted to get <code class="notranslate">runId</code>s for the new task, which did not exist.<br>
An error occured in the grid..js, but since the file is minified/obfuscated, it's unclear for me where exactly.</p>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">The grid should handle missing <code class="notranslate">runId</code> without causing an exception.</p>
<h3 dir="auto">How to reproduce</h3>
<ol dir="auto">
<li>Create a simple dag, with a few dummy tasks, and let it run a few times. Check out the grid (it should be okay).</li>
<li>After that, add a new dummy task, and check out the grid again. The grid's area will be empty, and the JS console will have the following error: <code class="notranslate">TypeError: Cannot read properties of null (reading 'runId')</code></li>
</ol>
<p dir="auto">Probably any other scenarios where the tasks run history is uneven, could also cause this error.</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Linux</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Virtualenv installation</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">Other Airflow 2 version</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">Airflow 2.3.3.<br>
Task instance failures produce duplicates in "task_fail" table for this constraint (dag_id, task_id, run_id, map_index).</p>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">Recently FK constraint between task_fail and task_instance tables was introduced:<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1168790336" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/22260" data-hovercard-type="pull_request" data-hovercard-url="/apache/airflow/pull/22260/hovercard" href="https://github.com/apache/airflow/pull/22260">#22260</a><br>
And then there was a change to purge duplicates for this constraint from task_fail table (on db upgrade):<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1193838101" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/22769" data-hovercard-type="pull_request" data-hovercard-url="/apache/airflow/pull/22769/hovercard" href="https://github.com/apache/airflow/pull/22769">#22769</a></p>
<p dir="auto">Removing duplicates on db upgrade to Airflow 2.3+ before establishing FK between tables makes sense, however these duplicates can occur in running Airflow 2.3+ instance (see "How to reproduce").</p>
<p dir="auto">What is rationale for removing duplicates once on upgrading to Airflow 2.3+ but keeping this possibility to generate duplicates again? Isn’t it going to break foreign key and integrity of these two tables?</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">Trigger DAG with task that fails multiple times for different tries, it will produce duplications in "task_fail" table.<br>
Example (two tries with 5 mins interval for retries):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="id | task_id |    dag_id    |          start_date           |           end_date            | duration | map_index |                run_id
1  | task    | dag1_failing | 2022-09-23 09:11:44.102894+00 | 2022-09-23 09:11:44.469007+00 |        0 |        -1 | scheduled__2022-09-22T00:00:00+00:00
3  | task    | dag1_failing | 2022-09-23 09:16:44.995269+00 | 2022-09-23 09:16:45.310398+00 |        0 |        -1 | scheduled__2022-09-22T00:00:00+00:00"><pre class="notranslate"><code class="notranslate">id | task_id |    dag_id    |          start_date           |           end_date            | duration | map_index |                run_id
1  | task    | dag1_failing | 2022-09-23 09:11:44.102894+00 | 2022-09-23 09:11:44.469007+00 |        0 |        -1 | scheduled__2022-09-22T00:00:00+00:00
3  | task    | dag1_failing | 2022-09-23 09:16:44.995269+00 | 2022-09-23 09:16:45.310398+00 |        0 |        -1 | scheduled__2022-09-22T00:00:00+00:00
</code></pre></div>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Linux</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Composer</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>