Skip to content

Commit bd89fb7

Browse files
kubasieronengelkem-strzelczyk
authored
Airflow DB Cleanup updates (GoogleCloudPlatform#9124)
* Fix and adjust to Airflow 2.3 db cleanup DAG * Remove cleanup Task and TaskSet tables * removing duplicated airflow_1 file + some minor fixes * Add analyze task to the DAG to properly calculate db size --------- Co-authored-by: Charles Engelke <[email protected]> Co-authored-by: Maciej Strzelczyk <[email protected]>
1 parent 40fcbd6 commit bd89fb7

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

composer/workflows/airflow_db_cleanup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,18 @@ def cleanup_function(**context):
361361
session.close()
362362

363363

364+
def analyze_db():
365+
session = settings.Session()
366+
session.execute("ANALYZE")
367+
session.commit()
368+
369+
370+
analyze_op = PythonOperator(
371+
task_id="analyze_query",
372+
python_callable=analyze_db,
373+
provide_context=True,
374+
dag=dag)
375+
364376
for db_object in DATABASE_OBJECTS:
365377

366378
cleanup_op = PythonOperator(
@@ -371,5 +383,6 @@ def cleanup_function(**context):
371383
dag=dag)
372384

373385
print_configuration.set_downstream(cleanup_op)
386+
cleanup_op.set_downstream(analyze_op)
374387

375388
# [END composer_metadb_cleanup]

0 commit comments

Comments
 (0)