v.20.11Improvement

Fix memory profiler settings and query_id for HTTP queries in ClickHouse

Fix memory_profiler_step/max_untracked_memory for queries via HTTP (test included). Fix the issue that adjusting this value globally in xml config does not help either, since those settings are not applied anyway, only default (4MB) value is used. Fix query_id for the most root ThreadStatus of the http query (by initializing QueryScope after reading query_id). #16101 (Azat Khuzhin).
Fix correct application of memory_profiler_step and max_untracked_memory settings for queries executed via HTTP, and ensure accurate query_id assignment for the root ThreadStatus of HTTP queries.

Why it matters

Addresses an issue where configuring memory_profiler_step and max_untracked_memory globally in the XML config had no effect on HTTP queries because default values were always used instead. Also fixes the query_id initialization for the root ThreadStatus to reflect the actual HTTP query ID. These fixes enhance memory profiling accuracy and query identification when using HTTP protocol.

How to use it

Set the memory_profiler_step and max_untracked_memory parameters either globally in the XML configuration or per query, and run queries via HTTP as usual. The fixes ensure these settings are respected without additional user action. The query_id will now correctly reflect the HTTP query's ID automatically.