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

sessionctx,store,kv: add a session variable to export last txn info (#19949) #20696

Merged
merged 3 commits into from
Nov 12, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #19949 to release-4.0


Signed-off-by: zyguan zhongyangguan@gmail.com

What problem does this PR solve?

Problem Summary: Currently we can get start ts from @@tidb_current_ts within a transaction, however there is no way to get commit ts. The testability can be improved a lot if we can access the commit ts (and may more info) of the last committed transaction.

What is changed and how it works?

What's Changed: Add a session variable, @@tidb_last_txn_info, which export timestamps of the last committed transaction.

How it Works: A new txn option CommitHook, which indicates a callback function with signature of func(TxnInfo, error), is added and will be called right after a transaction gets committed. In this callback function, we attach txn info to SessionVars and export ts fields as session variables.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • None

Release note

  • No release note, just an enhancement in testability

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@zyguan please accept the invitation then you can push to the cherry-pick pull requests.
https://github.com/ti-srebot/tidb/invitations

Signed-off-by: zyguan <zhongyangguan@gmail.com>
@cfzjywxk
Copy link
Contributor

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 28, 2020
Copy link
Contributor

@MyonKeminta MyonKeminta 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-srebot
Copy link
Contributor Author

@MyonKeminta, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: execution(slack).

Copy link
Contributor

@youjiali1995 youjiali1995 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-srebot
Copy link
Contributor Author

@youjiali1995, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: execution(slack).

@bb7133 bb7133 modified the milestones: v4.0.8, v4.0.9 Nov 4, 2020
Copy link
Member

@zz-jason zz-jason 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-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 12, 2020
@zz-jason
Copy link
Member

/merge

@ti-srebot
Copy link
Contributor Author

Your auto merge job has been accepted, waiting for:

  • 20955
  • 20830
  • 20712
  • 20907
  • 20954
  • 20921
  • 20829

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 12, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit ee324ef into pingcap:release-4.0 Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants