Petr Fedchenkov created IMPALA-15835:
----------------------------------------
Summary: Duplicate metric families in /metrics_prometheus when
statestored HA is enabled
Key: IMPALA-15835
URL: https://issues.apache.org/jira/browse/IMPALA-15835
Project: IMPALA
Issue Type: Bug
Components: Backend
Reporter: Petr Fedchenkov
With statestored HA ({{--enable_statestored_ha}}, IMPALA-12156), a
{{StatestoreSubscriber}} creates two
{{StatestoreStub}} instances, one per statestored. Each stub registers its
metrics
in its own child metric group ("statestore-subscriber" /
"statestore2-subscriber"),
but almost all metric keys are registered without the group prefix, so both
stubs
register identical keys (e.g.
{{statestore-subscriber.topic-$0.update-interval}}).
{{MetricGroup::ToPrometheus()}} flattens the child groups without prefixing the
group name and writes a {{# HELP}}/{{# TYPE}} block per registered metric
object.
As a result the {{/metrics_prometheus}} exposition of every subscriber process
contains each affected family twice with its own HELP/TYPE header, and every
standards-compliant text-format parser rejects the scrape:
{noformat}
parse prometheus exposition: text format parsing error in line 193: second HELP
line
for metric name
"impala_statestore_subscriber_topic_impala_request_queue_update_interval"
{noformat}
This breaks scraping of the admissiond, impalad and catalogd metrics pages
(every process holding a StatestoreSubscriber) whenever HA is enabled. In our
deployment the cluster autoscaler, which parses admissiond's exposition with
prometheus/common expfmt, failed every scrape tick and stopped making scaling
decisions until the statestored count was reduced back to one. A stock
Prometheus server tolerates repeated metadata but drops the duplicate samples
at ingest ({{ErrDuplicateSampleForTimestamp}}, counted as
{{prometheus_target_scrapes_sample_duplicate_timestamp_total}}), so half of the
exposed subscriber metrics are lost there too.
On a 2-statestored cluster a subscriber duplicates 8 stub metrics
(num-connection-failures, last-recovery-duration, topic-update-interval-time,
topic-update-duration, heartbeat-interval-time, num-update-catalogd-rpc,
num-update-statestored-role-rpc, num-re-register-attempt) plus the per-topic
{{processing-time-s}} and {{update-interval}} pair of every topic it subscribes
to, i.e. 8 + 2 * N_topics families in total: 12 on admissiond (the
{{impala-membership}} and {{impala-request-queue}} topics), 10 on catalogd
({{catalog-update}}). The duplicate copies also disagree: the standby stub's
counters stay at 0,
so Prometheus keeps one of two same-named series arbitrarily and dashboards flip
to zeros after a failover.
Proposed fix: prefix every stub metric key with the same name prefix the stub's
metric group already uses ("statestore-subscriber" / "statestore2-subscriber"),
register the matching MetricDefs entries in metrics.json, and add a unit test
asserting the exposition has no duplicate families. The keys of the first stub
stay unchanged, so single-statestored deployments and existing dashboards are
unaffected. A patch to follow.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)