potiuk commented on code in PR #29516:
URL: https://github.com/apache/airflow/pull/29516#discussion_r1106522839
##########
airflow/jobs/base_job.py:
##########
@@ -245,32 +246,47 @@ def heartbeat(self, only_if_necessary: bool = False):
# We didn't manage to heartbeat, so make sure that the timestamp
isn't updated
self.latest_heartbeat = previous_heartbeat
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def pre_execute(job: BaseJob, *, session: Session = NEW_SESSION) -> None:
+ """Update the database job entry before running the _execute()
function."""
+ job.state = State.RUNNING
+ session.add(job)
+ session.commit()
+ make_transient(job)
Review Comment:
I think there is a bigger problem here. BaseJob is an SQLAlchemy model and
we are effectively trying to serialize it with internal_api call. This is not
going to end well.
I think this is one of those cases where we need to do it differently and
refactor the code quite a bit deeper.
--
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]