This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new c68f44e2cf0 [v3-1-test] fix get latest serialized_dag model query to 
prevent "Out of sort memory" error (#55589) (#57042)
c68f44e2cf0 is described below

commit c68f44e2cf04032c1c9837eeceb6e8553be0d6d1
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Oct 23 15:10:19 2025 +0100

    [v3-1-test] fix get latest serialized_dag model query to prevent "Out of 
sort memory" error (#55589) (#57042)
    
    * [v3-1-test] Fix Outlet Event Extra Data is Empty in Task Instance Success 
Listener (#54568) (#57031)
    
    Co-authored-by: Kevin Yang <[email protected]>
    
    * [v3-1-test] fix get latest serialized_dag model query to prevent "Out of 
sort memory" error (#55589)
    
    * fix get latest serialized_dag model query
    
    * fix get latest serialized_dag model query
    
    * add db type check logic
    (cherry picked from commit 757db2739168571db4e00a67f16b7ada9039785e)
    
    Co-authored-by: Jeongwoo Do <[email protected]>
    
    ---------
    
    Co-authored-by: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
    Co-authored-by: Kevin Yang <[email protected]>
    Co-authored-by: Jeongwoo Do <[email protected]>
---
 airflow-core/src/airflow/models/serialized_dag.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/airflow-core/src/airflow/models/serialized_dag.py 
b/airflow-core/src/airflow/models/serialized_dag.py
index b6bbf67fae3..f0e9bd9c6da 100644
--- a/airflow-core/src/airflow/models/serialized_dag.py
+++ b/airflow-core/src/airflow/models/serialized_dag.py
@@ -460,6 +460,15 @@ class SerializedDagModel(Base):
 
     @classmethod
     def latest_item_select_object(cls, dag_id):
+        from airflow.settings import engine
+
+        if engine.dialect.name == "mysql":
+            # Prevent "Out of sort memory" caused by large values in cls.data 
column for MySQL.
+            # Details in https://github.com/apache/airflow/pull/55589
+            latest_item_id = (
+                select(cls.id).where(cls.dag_id == 
dag_id).order_by(cls.created_at.desc()).limit(1)
+            )
+            return select(cls).where(cls.id == latest_item_id)
         return select(cls).where(cls.dag_id == 
dag_id).order_by(cls.created_at.desc()).limit(1)
 
     @classmethod

Reply via email to