airflow-core/docs/core-concepts/task-and-asset-state-store.rst
.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
.. _concepts:task-and-asset-state-store-overview:
.. versionadded:: 3.3
Airflow has always modeled tasks as stateless, idempotent units of work. A growing class of workloads, however, require some amount of data to be persisted outside of a task's return value, like a submitted job ID that must survive a worker crash, a watermark that advances run-by-run, or a row counter exposed for observability. Task store and Asset store fill that gap without touching the XCom or Variable systems.
Task and Asset store provide two key/value stores to persist data like a job ID, watermark, or row count. These two stores are differentiated by what they are scoped to:
.. list-table:: :header-rows: 1 :widths: 20 25 25 30
clear_on_success = TrueBoth stores accept JSON-able values. Values can be stored using the default metastore backend, or be offloaded via a :ref:custom worker-side backend <task-and-asset-state-store:worker-backends>.
Use this table to choose the right mechanism for your use case.
.. list-table:: :header-rows: 1 :widths: 22 78
.. note::
If your current implementation already leverages an XCom-based pattern successfully, there's no need to migrate to task state store. Task store is meant to solve problems that XCom was never designed for.
Task State Store <task-state-store>: full API reference and use-case examplesAsset State Store </core-concepts/asset-state-store>: watermark pattern and API referenceTask and Asset State Store Configuration </administration-and-deployment/task-and-asset-state-store>: retention, GC, and custom backends