Lee-W commented on code in PR #66854:
URL: https://github.com/apache/airflow/pull/66854#discussion_r3265235699


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -457,6 +457,12 @@ def ti_update_state(
                 extra=json.dumps({"host_name": hostname}) if hostname else 
None,
             )
         )
+        # Commit the TI state update now to release the task_instance row lock 
before
+        # running asset-event queries. Asset registration can hold the lock 
for seconds
+        # under high concurrency (many aliases with large event histories), 
causing
+        # idle-in-transaction pile-up that exhausts API server memory and 
triggers OOMKill.
+        # The task outcome is durable from this point on.
+        session.commit()

Review Comment:
   Is this still needed after changes in the alias side? I'm asking because of 
the silent dropping here 
https://github.com/apache/airflow/pull/66854/changes#diff-680cf6d70e96761db3869142642ba1df32e5c2c5c8d1b9ab65d0200dca4718daR500.
 or could we have better handling there? 



##########
airflow-core/tests/unit/assets/test_manager.py:
##########
@@ -162,6 +163,90 @@ def test_register_asset_change_with_alias(
         )
         assert 
session.scalar(select(func.count()).select_from(AssetDagRunQueue)) == 2
 
+    def test_register_asset_change_with_alias_no_lazy_load(
+        self, session, mock_task_instance, testing_dag_bundle
+    ):
+        """Regression: alias-event association must use a direct INSERT, not 
ORM .append().
+
+        ORM .append() lazy-loads the entire asset_events collection before 
writing.
+        On long-running deployments with thousands of past events, this query 
runs
+        while the task_instance row lock is held in ti_update_state, causing 
idle-in-transaction
+        pile-up that exhausts API server memory and triggers OOMKill.
+        """
+        from sqlalchemy import insert as sa_insert

Review Comment:
   Why not import from the top level? and why the rename



-- 
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]

Reply via email to