saguziel commented on a change in pull request #7269: [AIRFLOW-6651] Add Redis 
Heartbeat option
URL: https://github.com/apache/airflow/pull/7269#discussion_r383526519
 
 

 ##########
 File path: airflow/jobs/base_job.py
 ##########
 @@ -102,7 +112,16 @@ def most_recent_job(cls, session=None) -> 
Optional['BaseJob']:
         :param session: Database session
         :rtype: BaseJob or None
         """
-        return 
session.query(cls).order_by(cls.latest_heartbeat.desc()).limit(1).first()
+        latest_job_sql = 
session.query(cls).order_by(cls._legacy_heartbeat.desc()).limit(1).first()
+        if conf.getboolean('heartbeat', 'redis_enabled'):
+            latest_id = cls.redis.zrange(cls.__name__, -1, -1)
 
 Review comment:
   This is only for reads. I'll add a clarifying comment but the gist is the 
first heartbeat doesn't have a good place to write it without a race condition 
since the .id is unavailable in __init__ and is only available after the 
session is flushed. So the legacy heartbeat should only be written at creation 
time. This is more or less the same as start_time

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to