Skip to content

[v3-3-test] Report Dag cache metrics under each component's own namespace (#71815) - #71925

Open
jason810496 wants to merge 1 commit into
apache:v3-3-testfrom
jason810496:backport-bcf1dbf-v3-3-test
Open

[v3-3-test] Report Dag cache metrics under each component's own namespace (#71815)#71925
jason810496 wants to merge 1 commit into
apache:v3-3-testfrom
jason810496:backport-bcf1dbf-v3-3-test

Conversation

@jason810496

Copy link
Copy Markdown
Member

Why

Every configured DBDagBag emitted cache counters under api_server.dag_bag.*. Once the scheduler gained a bounded cache in #71704, scheduler traffic was counted against the API server's series, so operators could not distinguish the two components.

The cache settings and metrics also made every DBDagBag caller opt into an interface intended only for long-lived component caches.

How

DBDagBag remains the simple base implementation for callers that do not configure eviction or cache metrics. CachedDBDagBag owns LRU, TTL, and no-eviction cache modes, along with thread safety and the required component metric namespace.

The API server always constructs CachedDBDagBag from its cache configuration. With size and TTL both set to 0, the subclass uses a plain unbounded dict and performs no eviction. The scheduler constructs CachedDBDagBag under scheduler.dag_bag.*.

The metrics registry check now matches every static part of a dynamic metric name, including names assembled from a caller-supplied prefix.

What

  • Reports API server cache metrics under api_server.dag_bag.*.
  • Reports scheduler cache metrics under scheduler.dag_bag.*.
  • Keeps short-lived and compatibility callers on the base DBDagBag.
  • Preserves the existing 0/0 no-eviction behavior while keeping configured component caches on CachedDBDagBag.

cherry picked from commit bcf1dbf)

…pace (apache#71815)

* Report Dag cache metrics under each component's own namespace

Every DBDagBag emitted its cache counters under api_server.dag_bag.*, so once the
scheduler gained a cache its traffic was silently counted against the API
server's series. An operator reading cache_hit or cache_size could not tell the
two components apart, and the API server's numbers became wrong rather than
merely incomplete.

Each caller now supplies the namespace it reports under, and a cache built
without one fails at construction instead of emitting a partially-formed metric
name mid-request.

The registry check matched dynamic metric names only by the static prefix ahead
of their first variable, which cannot express a name assembled from a caller
supplied prefix. It now matches on all static parts wherever the variable sits.

* Scope Dag cache configuration to cached database Dag bags

DBDagBag is used by callers that do not configure cache eviction or metrics. Keeping those concerns behind a dedicated subtype prevents optional constructor combinations and makes metric ownership explicit.

* Preserve no-eviction Dag cache configuration

* Avoid redundant Dag cache checks
(cherry picked from commit bcf1dbf)

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:dev-tools area:Scheduler including HA (high availability) scheduler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant