Il 15 settembre 2026, tutti gli ambienti Cloud Composer 1 e Cloud Composer 2 versione 2.0.x raggiungeranno la fine del ciclo di vita pianificata e non potrai più utilizzarli. Ti consigliamo di pianificare la migrazione a Cloud Composer 3.
Questa pagina spiega come gestire il database Airflow nel tuo ambiente.
Pulizia automatica del database con una policy di conservazione del database
Puoi configurare la pulizia automatica del database per il tuo ambiente Cloud Composer 3 impostando un criterio di conservazione del database. Dopo aver configurato questo
piano, i record precedenti a un determinato periodo vengono rimossi automaticamente ogni giorno dal
database Airflow. Per ulteriori informazioni, consulta la pagina sulla
configurazione del criterio di conservazione del database.
Procedure di pulizia ritirate
Prima che il criterio di conservazione del database diventasse disponibile in Cloud Composer, consigliavamo un approccio diverso per automatizzare la pulizia del database tramite un DAG di pulizia del database. Questo approccio è obsoleto in Cloud Composer 3. Questo DAG esegue un'operazione ridondante e puoi ridurre il consumo di risorse rimuovendolo e sostituendolo con un
criterio di conservazione del database.
Limiti per le dimensioni del database
Con il passare del tempo, il database Airflow del tuo ambiente archivia sempre più dati. Questi dati includono informazioni e log relativi a esecuzioni DAG, attività e altre operazioni Airflow passate.
Se le dimensioni del database Airflow superano i 20 GB, non puoi eseguire l'upgrade dell'ambiente a una versione successiva.
Se le dimensioni del database Airflow sono superiori a 20 GB,
non è possibile creare snapshot.
Mantenere le prestazioni del database
I problemi di prestazioni del database Airflow possono causare problemi di esecuzione complessiva dei DAG.
Osserva le statistiche sull'utilizzo della CPU e della memoria del database. Se l'utilizzo della CPU e della memoria si avvicina ai limiti, il database è sovraccaricato e richiede lo scaling.
La quantità di risorse disponibili per il database Airflow è controllata dalla proprietà dimensione dell'ambiente. Per eseguire lo scaling del database verso l'alto, modifica le dimensioni dell'ambiente impostandole su un livello più grande. L'aumento delle dimensioni dell'ambiente ne aumenta i costi.
Se utilizzi il meccanismo XCom per trasferire i file, assicurati di utilizzarlo in base alle linee guida di Airflow.
Il trasferimento di file di grandi dimensioni o di un numero elevato di file utilizzando XCom influisce sul rendimento del database Airflow e può causare errori durante il caricamento degli snapshot o l'upgrade dell'ambiente. Valuta la possibilità di utilizzare alternative come Cloud Storage per trasferire grandi volumi di dati.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-29 UTC."],[[["\u003cp\u003eThis page outlines how to manually clean up the Airflow database in Cloud Composer 3 environments, as well as automatic alternatives.\u003c/p\u003e\n"],["\u003cp\u003eCloud Composer offers a database retention policy that automatically removes records older than a specified period, and it is preferred over the older database cleanup DAG.\u003c/p\u003e\n"],["\u003cp\u003eExceeding a 20 GB database size in Airflow prevents environment upgrades and snapshot creation, making regular cleanup essential.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud composer environments run\u003c/code\u003e command can be used to manually trim the database, removing entries older than the specified retention period.\u003c/p\u003e\n"],["\u003cp\u003eDatabase performance issues can cause DAG execution problems, and scaling up the environment size can address these issues, while also using proper Xcom practices to avoid issues with the database.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n**Cloud Composer 3** \\| [Cloud Composer 2](/composer/docs/composer-2/cleanup-airflow-database \"View this page for Cloud Composer 2\") \\| [Cloud Composer 1](/composer/docs/composer-1/cleanup-airflow-database \"View this page for Cloud Composer 1\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page explains how to maintain the Airflow database in your environment.\n\nAutomatic database cleanup with a database retention policy\n\nYou can configure automatic database cleanup for your Cloud Composer 3\nenvironment by setting a database retention policy. After you set up this\npolicy, records older than a certain period are automatically removed from the\nAirflow database daily. For more information, see\n[Configure database retention policy](/composer/docs/composer-3/configure-db-retention).\n\nDeprecated cleanup procedures **Deprecated:** The **maintenance DAG approach is obsolete** in Cloud Composer 3. If you still use the database maintenance DAG, we recommend to remove or pause it and configure a [database retention policy](/composer/docs/composer-3/configure-db-retention) instead.\n\nBefore the database retention policy became available in\nCloud Composer, we recommended a different approach for automating\nthe database cleanup, through a [database cleanup DAG](/composer/docs/composer-2/cleanup-airflow-database). This\napproach is obsolete in Cloud Composer 3. This DAG does redundant work and you\ncan reduce the resource consumption by removing it and replacing it with a\n[database retention policy](/composer/docs/composer-3/configure-db-retention).\n\nLimits for database size\n\nAs the time goes, the Airflow database of your environment stores more and\nmore data. This data includes information and logs related to past DAG runs,\ntasks, and other Airflow operations.\n\n- If the Airflow database size is more than\n 20 GB,\n then you can't upgrade your environment to a later version.\n\n- If the Airflow database size is more than 20 GB,\n it is not possible to create snapshots.\n\nMaintain database performance\n\n- Airflow database performance issues can lead to overall DAG execution\n issues.\n [Observe Database CPU and memory usage](/composer/docs/composer-3/use-monitoring-dashboard#db-statistics)\n statistics. If CPU and memory utilization approaches the limits, then the\n database is overloaded and requires scaling.\n\n The amount of resources available to the Airflow database is controlled by\n the environment size property of your environment. To scale the database up\n [change the environment size](/composer/docs/composer-3/scale-environments) to a larger tier. Increasing the\n environment size increases the costs of your environment.\n\n- If you use the XCom mechanism to transfer files, make sure that you\n [use it according to Airflow's guidelines](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/xcoms.html#object-storage-xcom-backend).\n Transferring big files or a large number of files using XCom impacts\n Airflow database's performance and can lead to failures when loading\n snapshots or upgrading your environment. Consider using alternatives such\n as Cloud Storage to transfer large volumes of data.\n\nRemove entries for unused DAGs\n\nYou can remove database entries for unused DAGs by\n[removing DAGs from the Airflow UI](/composer/docs/composer-3/manage-dags#delete-md).\n\nWhat's next\n\n- [Configure database retention policy](/composer/docs/composer-3/configure-db-retention)\n- [Access Airflow command-line interface](/composer/docs/composer-3/access-airflow-cli)"]]