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

Print Txn ID and Query ID in log to trace the whole lifetime of a Txn / SQL #17845

Open
breezewish opened this issue Jun 8, 2020 · 1 comment
Labels
feature/accepted This feature request is accepted by product managers sig/transaction SIG:Transaction type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@breezewish
Copy link
Member

breezewish commented Jun 8, 2020

Feature Request

Is your feature request related to a problem? Please describe:

TiDB now outputs TxnStartTs or ConnId in logs, which is not sufficient.

Cons of TxnStartTs:

  • A transaction may include multiple SQLs. Cannot distinguish different SQLs in the same transaction.
  • TxnStartTs may not be unique even for different transactions, e.g. it can be MaxUint64.

Cons of ConnId:

  • A connection can send multiple SQLs or transactions, cannot distinguish.
  • ConnId is even not send to TiKV so that TiKV and TiDB logs cannot be linked together.

Describe the feature you'd like:

  • For each transaction, assign a globally unique TxnId. The id can be generated by randomize in uint64.

  • For each query, assign a globally unique QueryId. The id can be generated by randomize in uint64.

  • Both TiDB and TiKV logs outputs the TxnId and QueryId, for example, in slow logs, conflict logs, back off logs, etc.

This simplifies the process to diagnose problems from logs: users should be able know everything (log) about a transaction by only grep the TxnId, and know everything (log) about a query by only grep the QueryId.

Describe alternatives you've considered:

TxnId and QueryId can be derived from a global Connection Id, in order to be able to associate Transaction / Query with Connection. However looks like it doesn't need to be this complicated, since we can print connection id in the log at the same time in the log together with TxnId and QueryId. In this way, user can know the connection id by simply grep either TxnId or QueryId.

Teachability, Documentation, Adoption, Migration Strategy:

@breezewish breezewish added the type/feature-request Categorizes issue or PR as related to a new feature. label Jun 8, 2020
@djshow832 djshow832 added the sig/transaction SIG:Transaction label Jun 8, 2020
@breezewish
Copy link
Member Author

Related task: #15638

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/accepted This feature request is accepted by product managers sig/transaction SIG:Transaction type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants