Skip to content
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

*: add session alias field in slowlog, general log and extension framework #46273

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Aug 21, 2023

What problem does this PR solve?

Issue Number: close #46272, ref #46071

What is changed and how it works?

After set @@tidb_session_alias='alias123' , you can see a field named Session_alias in slow log output:

# Time: 2023-08-21T15:06:02.507248+08:00
# Txn_start_ts: 0
# User@Host: root[root] @ 127.0.0.1 [127.0.0.1]
# Conn_ID: 2097154
# Session_alias: alias123
# Query_time: 1.002047042
# Parse_time: 0.000107792
...

for table information_schema.SLOW_QUERY

TiDB root@127.0.0.1:test> select * from information_schema.SLOW_QUERY where session_alias='alias123'\G
***************************[ 1. row ]***************************
Time                          | 2023-08-21 15:06:02.507248
Txn_start_ts                  | 0
User                          | root
Host                          | 127.0.0.1
Conn_ID                       | 2097154
Session_alias                 | alias123
Exec_retry_count              | 0
Exec_retry_time               | 0.0
...
TiDB root@127.0.0.1:test> admin show slow recent 1;
+-----------------+----------------------------+----------+---------+------+---------+----------------+--------+------+-----------+-----------+----------+------------------------------------------------------------------+---------------+
| SQL             | START                      | DURATION | DETAILS | SUCC | CONN_ID | TRANSACTION_TS | USER   | DB   | TABLE_IDS | INDEX_IDS | INTERNAL | DIGEST                                                           | SESSION_ALIAS |
+-----------------+----------------------------+----------+---------+------+---------+----------------+--------+------+-----------+-----------+----------+------------------------------------------------------------------+---------------+
| select sleep(1) | 2023-08-21 15:06:01.505137 | 0:00:01  |         | 1    | 2097154 | 0              | root@% | test |           |           | 0        | a0adeeb79b71315ac13a77f3f11162106b5ec7b48212cf17c20c754263ab9228 | alias123      |
+-----------------+----------------------------+----------+---------+------+---------+----------------+--------+------+-----------+-----------+----------+------------------------------------------------------------------+---------------+

for general log:

[2023/08/21 15:06:01.505 +08:00] [INFO] [session.go:3957] [GENERAL_LOG] [conn=2097154] [session_alias=alias123] [user=root@127.0.0.1] [schemaVersion=137] [txnStartTS=0] [forUpdateTS=0] [isReadConsistency=false] [currentDB=test] [isPessimistic=false] [sessionTxnMode=PESSIMISTIC] [sql="select sleep(1)"]

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

add session alias field in slowlog, general log and extension framework

@lcwangchao lcwangchao requested a review from a team as a code owner August 21, 2023 06:59
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 21, 2023
@lcwangchao lcwangchao force-pushed the session_alias_slow_log branch from 98999c0 to 9edcd37 Compare August 21, 2023 07:00
@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #46273 (9942f44) into master (ab4d6ad) will decrease coverage by 0.9646%.
Report is 26 commits behind head on master.
The diff coverage is 92.8571%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #46273        +/-   ##
================================================
- Coverage   73.3860%   72.4214%   -0.9646%     
================================================
  Files          1285       1305        +20     
  Lines        394834     402331      +7497     
================================================
+ Hits         289753     291374      +1621     
- Misses        86637      92486      +5849     
- Partials      18444      18471        +27     
Flag Coverage Δ
integration 25.8561% <15.3846%> (?)
unit 73.3585% <92.8571%> (-0.0276%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0775% <ø> (ø)
br 47.2245% <ø> (-5.0383%) ⬇️

@lcwangchao lcwangchao force-pushed the session_alias_slow_log branch 2 times, most recently from 1bcecb1 to 137e859 Compare August 21, 2023 09:24
@lcwangchao
Copy link
Collaborator Author

/retest

@lcwangchao lcwangchao force-pushed the session_alias_slow_log branch from 137e859 to 9942f44 Compare August 22, 2023 01:24
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 23, 2023
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 23, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 23, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-23 07:45:03.323875189 +0000 UTC m=+1308267.872891171: ☑️ agreed by bb7133.
  • 2023-08-23 08:31:11.796190307 +0000 UTC m=+1311036.345206293: ☑️ agreed by tiancaiamao.

@easonn7
Copy link

easonn7 commented Aug 23, 2023

/approve

@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, easonn7, tiancaiamao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Aug 23, 2023
@ti-chi-bot ti-chi-bot bot merged commit 6dd4a3a into pingcap:master Aug 23, 2023
@lcwangchao lcwangchao deleted the session_alias_slow_log branch August 25, 2023 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add session alias field in slowlog, general log and extension framework
4 participants