Repository navigation
Cherry pick #123622 to 26.9: Send the query id with OpenAI AI function requests - #127873
Conversation
`OpenAIProvider` sends `X-ClickHouse-Query-Id` with `initial_query_id`, or `current_query_id` for a background mutation, which has no initial query. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The `X-ClickHouse-Query-Id` header now carries the query id of the query that makes the request. On a remote shard it is the shard's own query id, which identifies the exact server that made the request and from which the `initial_query_id` can be reconstructed via `system.query_log`. This is also consistent with how the query id is exposed elsewhere. A background mutation sends its task's `current_query_id`, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m query id headers The initial query id lets the endpoint group the requests of a distributed query. Query ids from the native and gRPC protocols are not sanitized, so control characters could inject extra headers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… only `query_id` - Introduce a base struct `AIRequest` with the fields common to chat and embedding requests (`function_name`, `query_id`); the chat request is renamed to `AIChatRequest` and both it and `AIEmbeddingRequest` inherit from the base. - Sanitize the `X-ClickHouse-Query-Id` header with the existing `sanitizeForLog` (control characters become spaces) instead of a duplicated helper. - Drop the `X-ClickHouse-Initial-Query-Id` header: the shard's own `query_id` is sufficient, and the initial query id can be reconstructed from it. - Remove redundant comments. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`X-ClickHouse-Query-Id` carries the current query id, `X-ClickHouse-Initial-Query-Id` the initial one, which is the same on all shards of a distributed query. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Send the query id with OpenAI AI function requests
|
@groeneai please resolve the merge conflicts in this cherry-pick (
for (const auto & header : getHeaders())
http_request.set(header.name, header.value);
setCommonHeaders(http_request, ai_request); |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Resolved as you described:
Every resolved region is byte-identical to master. Against Validated on the 26.9 tree with clang-22, debug build: The merge is on my fork and its first parent is this PR's head, so applying it is a fast-forward: (resolved head |
Original pull-request #123622
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job