-
Notifications
You must be signed in to change notification settings - Fork 6.2k
*: support logging session connect attrs to slow query log #66617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ti-chi-bot
merged 11 commits into
pingcap:master
from
jiong-nba:feature/slow-log-session-attrs
Mar 23, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b158fff
support logging session connect attrs to slow query log
jiong-nba 235e0c2
build: update bazel target for parse package missing dependencies
jiong-nba cd641cd
server, sessionctx: refine connect attrs handling and slow log output
jiong-nba 80680e8
server, executor, sessionctx: refine session connect attrs slow log b…
jiong-nba 8367cf5
pkg/server,pkg/executor,pkg/sessionctx: refine session connect attrs …
jiong-nba d5eaccc
pkg/executor,pkg/infoschema: add testutil bazel deps
jiong-nba 34dde23
server: disable session attrs when connect attrs size is 0
jiong-nba 25c0682
pkg/infoschema: fix slow_query TestSlowQuery attrs expectation
jiong-nba 9ea93a8
pkg/sessionctx/variable/tests: update bazel shard count
jiong-nba 8907a87
pkg/sessionctx/variable/tests: update bazel shard count after rebase
jiong-nba 871eecf
pkg/infoschema: fix slow query session attrs expectation
jiong-nba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
Each slow statement now serializes connection attributes, but payload size is bounded only by handshake/session attribute limits, not by a dedicated slow-log emission cap.
Scope
pkg/executor/adapter_slow_log.go:267; pkg/sessionctx/variable/slow_log.go:560; pkg/sessionctx/variable/sysvar.go:684
Risk if unchanged
Under high slow-query volume, per-row payload growth can increase slow-log I/O and downstream parse cost (
information_schema.slow_query), worsening tail latency and disk pressure during incidents.Evidence
SetSlowLogItemsattachessessVars.ConnectionInfo.Attributesto each slow-log item;SlowLogFormatJSON-encodes and writes it when non-empty;performance_schema_session_connect_attrs_sizeallows up to 65536 bytes (-1normalized to 64KiB in parse logic).Change request
Add a slow-log-specific emission cap (or dedicated sysvar) for
Session_connect_attrs, and expose truncation/drop observability so operators can bound and monitor log amplification.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maximum value of performance_schema_session_connect_attrs_size is 64 KB, making the associated overhead relatively manageable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in most cases, the connection attribute will not be very large. However, in extreme cases, 64 KB is indeed significantly larger than the size of all current existing columns, and it has little significance to retain. We can confirm with the PM again whether to adjust it, such as adding a switch for control.