Skip to content

fix: show rule identity instead of backend identity in SHOW POOLS#1292

Open
douyux wants to merge 1 commit intoyandex:masterfrom
douyux:fix/dup-metrics-rows
Open

fix: show rule identity instead of backend identity in SHOW POOLS#1292
douyux wants to merge 1 commit intoyandex:masterfrom
douyux:fix/dup-metrics-rows

Conversation

@douyux
Copy link
Copy Markdown

@douyux douyux commented Mar 18, 2026

Problem

SHOW POOLS and SHOW POOLS_EXTENDED report route->id.database and
route->id.user in the database and user columns. These fields
represent the backend connection identity — they are overridden by
storage_db / storage_user directives during routing.

When multiple frontend routing rules map to the same backend credentials,
all affected routes produce rows with identical (database, user) values,
making them indistinguishable. This causes two concrete problems:

  1. Observability gap — operators cannot correlate pool metrics back to
    specific routing rules.
  2. Prometheus label collision — duplicate label sets corrupt metric
    series and break scraping.

Fix

Replace route->id.database / route->id.user with
route->rule->db_name / route->rule->user_name in
od_console_show_pools_add_cb() (sources/console.c).

These fields always hold the frontend rule identity (the name as
written in the config file), which is unique per route. For default
rules they resolve to the literal strings "default_db" /
"default_user".

The length fields are updated accordingly: rule->db_name_len and
rule->user_name_len are assigned via strlen() and do not include the
null terminator, so the previous - 1 adjustment is dropped.

Behaviour change

Scenario Before After
No storage_db / storage_user client DB / user rule DB / user (same)
storage_user = backend_user configured backend_user rule user name
Multiple rules → same backend duplicate rows distinct rows per rule

Operators who relied on SHOW POOLS to inspect the actual backend
credentials should use SHOW SERVERS instead, which continues to reflect
the real backend connection identity.

Fixes #1279.

SHOW POOLS and SHOW POOLS_EXTENDED were reporting route->id.database
and route->id.user, which reflect backend credentials (potentially
overridden by storage_db/storage_user). When multiple routing rules
map to the same backend credentials, this produced duplicate rows
with identical (database, user) pairs, breaking observability and
causing Prometheus metric label collisions.

Fix by using route->rule->db_name and route->rule->user_name, which
always reflect the frontend routing rule identity.

Fixes yandex#1279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SHOW POOLS_EXTENDED Produces Indistinguishable Rows When Multiple Rules Share the Same Backend DB/User

1 participant