Uh oh!
There was an error while loading. Please reload this page.
AIP-103: Worker side custom state backend support - #66859
Conversation
Uh oh!
There was an error while loading. Please reload this page.
uranusjr
left a comment
There was a problem hiding this comment.
Do we already have a public state backend interface, or is this to be done later? (I’ve not been following closely.)
amoghrajesh
commented
May 19, 2026
@uranusjr its already present, |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jason810496
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
amoghrajesh
commented
May 20, 2026
Thanks for the detailed review folks, merging this one in |
Uh oh!
There was an error while loading. Please reload this page.
closes: #66337
What
The default path for task/asset state routes all reads and writes through the Execution API →
MetastoreStateBackend→ DB. Some deployments can't use this:Same constraint that motivated custom XCom and secrets backends.
What's being done
New config key
[workers] state_backendis introduced a fully-qualified class path to a customBaseStateBackendsubclass. If not set, nothing changes.When configured:
set(key, value)— callsbackend.serialize_task_state_value(), which stores the value externally and returns a reference string. That reference goes to DB.get(key)— fetches the reference from DB, passes it tobackend.deserialize_task_state_value(), which resolves it back to the actual value.delete(key)— callsbackend.delete(scope, key)withsession=Noneso the backend can clean up external storage, then removes the DB reference via comms.clear()— callsbackend.clear(scope)withsession=Nonefor external cleanup, then clears DB refs via comms.Interface changes to
BaseStateBackendTwo new method pairs with no-op defaults (existing backends don't need to change):
serialize_task_state_value(*, value, key, ti_id)/serialize_asset_state_value(*, value, key, asset_name)— called duringset(). Store externally, return a reference string for DB.deserialize_task_state_value(stored)/deserialize_asset_state_value(stored)— called duringget(). Resolve reference back to actual value.For
delete()andclear(), the existing abstract methods are reused. When called withsession=Noneit signals worker-side — clean up external storage only, don't touch DB (DB is cleaned separately via comms).AssetScopenow also acceptsnameandurifields since workers don't have access to the integerasset_id.End-to-end flow
Default path:
Custom backend:
What does a custom state backend author have to do?
Import from
airflow.sdk.state(notairflow._shared.state) — this gives access to task-sdk internals includingSUPERVISOR_COMMSif needed.Configure via
airflow.cfg:Testing
Wrote a custom state backend which is an in memory backend, ie: retrieves and stores from a dictionary. This backend stores actual values in a dict and stores only a
reference string (
mem://<namespace>/<key>) in the metadata DBCode:
Testing task_state
Starting breeze with this:
export AIRFLOW__WORKERS__STATE_BACKEND=memory_state_backend.MemoryStateBackendset + get:
get after delete:

clear:

DB only has refs left for task 1
Testing asset_state
Using a dag and linking it to multiple tasks and managing asset states
DAG:
set + get:

get after delete:
clear:
Once clear is called, all rows will be deleted for asset state since it isn't task scoped, so DB is empty
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.