AIrflow scheduler command crashes with sqlalchemy.exc.InternalError: (psycopg2.errors.InFailedSqlTransaction)

Viewed 191

When I run airflow scheduler in terminal it always crashes with

  File "/home/ec2-user/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1803, in _execute_context
    cursor, statement, parameters, context
  File "/home/ec2-user/.local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.InternalError: (psycopg2.errors.InFailedSqlTransaction) current transaction is aborted, commands ignored until end of transaction block

[SQL: UPDATE job SET state=%(state)s WHERE job.job_type = %(job_type_1)s AND job.state = %(state_1)s AND job.latest_heartbeat < %(latest_heartbeat_1)s AND job.job_type IN (%(job_type_2_1)s)]
[parameters: {'state': <TaskInstanceState.FAILED: 'failed'>, 'job_type_1': 'SchedulerJob', 'state_1': <TaskInstanceState.RUNNING: 'running'>, 'latest_heartbeat_1': datetime.datetime(2022, 2, 1, 13, 6, 22, 941318, tzinfo=Timezone('UTC')), 'job_type_2_1': 'SchedulerJob'}]
(Background on this error at: https://sqlalche.me/e/14/2j85)
[2022-02-01 13:10:24 +0000] [20329] [INFO] Shutting down: Master

Environment: Amazon Linux AMI; Airflow 2.2.3; psql 13.5

Command airflow db init works fine. Airflow UI also says that The scheduler does not appear to be running. Last heartbeat was received a few seconds ago. so the scheduler can connect to psql.

What am I doing wrong?

0 Answers
Related