Skip to content

Fix queries with same query_id on different hosts being deduplicated#240

Merged
azat merged 4 commits intomainfrom
same-query-ids
Apr 16, 2026
Merged

Fix queries with same query_id on different hosts being deduplicated#240
azat merged 4 commits intomainfrom
same-query-ids

Conversation

@azat
Copy link
Copy Markdown
Owner

@azat azat commented Apr 16, 2026

No description provided.

azat and others added 4 commits April 16, 2026 10:40
HashMap was keyed by query_id alone, so cluster queries with the same
query_id on multiple hosts (e.g. ON CLUSTER DDL) would overwrite each
other. Use (query_id, host_name) composite key instead.

Though note that i.e. logs/traces/perfetto will show data for all
queries with the same query_id.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
queries_count_subqueries and queries_sum_profile_events were keyed by
initial_query_id alone. When the same initial_query_id existed on
multiple cluster hosts, subquery counts were summed across hosts and
profile events were merged, making cpu/io_wait/cpu_wait identical for
all hosts. Key by (initial_query_id, host_name) instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The query_id_to_host map was 1:1, so when the same query_id appeared on
multiple cluster hosts only the last-seen host survived. All per-server
Perfetto tracks (counters, spans, logs, stack traces, etc.) were then
attributed to the wrong host.

Add hostName() to all Perfetto data source SQL queries so each row
carries its actual origin host, and pass it directly to
get_host_category_track instead of the lossy query_id lookup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
selected_query_ids was HashSet<String> (query_id only), so selecting a
query with a duplicate query_id on another host would select both.
This also caused the profile events diff view to include wrong queries.

Change to HashSet<QueryKey> ((query_id, host_name)) so selection,
diff view, and query_id collection for flamegraphs/logs/perfetto all
respect the host boundary.

Stop mutating host_name for display stripping — use a separate
display_host_name field instead, so query_key() always returns the
original hostname and selection/lookup works correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@azat azat merged commit db745f9 into main Apr 16, 2026
8 checks passed
@azat azat deleted the same-query-ids branch April 16, 2026 10:04
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.

1 participant