Airflow install broken. `table dag_stats already exists`
Asked Answered
O

2

4

My Airflow install has stopped working. UI Webserver doesn't come up. I think the problem is related to the following error that appears when I run

> airflow initdb

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table dag_stats already exists
[SQL: 
CREATE TABLE dag_stats (
    dag_id VARCHAR(250) NOT NULL, 
    state VARCHAR(50) NOT NULL, 
    count INTEGER NOT NULL, 
    dirty BOOLEAN NOT NULL, 
    PRIMARY KEY (dag_id, state), 
    CHECK (dirty IN (0, 1))
)

]

Does anyone know how to fix this so I can get back to work?

Opsonin answered 2/2, 2021 at 3:54 Comment(1)
But the webserver still won't come up. Anyone know how to diagnose that?Opsonin
O
13

I just deleted the database

> rm ~/airflow/airflow.db

and initialized a new one with

> airflow initdb

which works now.

Opsonin answered 2/2, 2021 at 4:25 Comment(3)
Answer is not working for WSL airflow instance. when doing remove automatically new db is getting created.Underwater
I have never used WSL, but I'm curious if employing airflow resetdb gives better results.Opsonin
actually , it does not work after resetting DB on WSL. I had to shut down WSL and then deleted content of ~/airflow and then started Airflow instance from start with DB init -> create user-> webserver -> scheduler . Then it started running again.Underwater
W
0

airflow command is changed. For the recent version i.e. 2.8.1, command for init db is "airflow db init"

Woodwind answered 20/2 at 17:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.