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

session: track LastCommitTS in SessionVars and check timestamps of later txns are larger #57305

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

b6g
Copy link
Contributor

@b6g b6g commented Nov 12, 2024

What problem does this PR solve?

Issue Number: close #57165

Problem Summary:

This PR checks the invariant that timestamps of transactions in a session should increase monotonically.

It saves the timestamp of the last transaction in SessionVars, after the transaction is committed. The saved timestamp is compared with the start_ts and the commit_ts of the next transaction.

This PR depends on the TiKV client-go PR, tikv/client-go#1489, which exports commit_ts of the transaction.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked labels Nov 12, 2024
Copy link

ti-chi-bot bot commented Nov 12, 2024

Hi @b6g. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Nov 12, 2024
Copy link

ti-chi-bot bot commented Nov 12, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign benmeadowcroft, djshow832 for approval, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

tiprow bot commented Nov 12, 2024

Hi @b6g. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@@ -929,6 +929,21 @@ func (s *session) CommitTxn(ctx context.Context) error {
s.sessionVars.StmtCtx.MergeExecDetails(nil, commitDetail)
}

if err == nil {
// save CommitTS in sessionVars for invariant check
// TODO: enable LastCommitTS with a session variable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a session variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in a separate PR #57313, to make review easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per discussion in #57313 (comment), we don't need a session variable.

pkg/sessiontxn/isolation/base.go Outdated Show resolved Hide resolved
@b6g b6g force-pushed the b6g/tsinvariant1 branch from e8df58f to e053b6f Compare November 12, 2024 07:04
@b6g b6g force-pushed the b6g/tsinvariant1 branch 2 times, most recently from 5cc54f3 to 8297ca5 Compare November 17, 2024 08:39
@dveeden
Copy link
Contributor

dveeden commented Nov 18, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Nov 18, 2024
go.mod Outdated Show resolved Hide resolved
@b6g b6g force-pushed the b6g/tsinvariant1 branch 2 times, most recently from 4e39c69 to 31193ac Compare November 19, 2024 03:38
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 73.1517%. Comparing base (1521bf7) to head (3ec86a7).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57305        +/-   ##
================================================
- Coverage   73.1843%   73.1517%   -0.0327%     
================================================
  Files          1674       1674                
  Lines        461690     461717        +27     
================================================
- Hits         337885     337754       -131     
- Misses       103042     103208       +166     
+ Partials      20763      20755         -8     
Flag Coverage Δ
unit 72.2766% <75.0000%> (-0.0350%) ⬇️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 46.0013% <ø> (+0.0120%) ⬆️

@b6g b6g force-pushed the b6g/tsinvariant1 branch 3 times, most recently from fbfaf0f to 3c7fb77 Compare November 27, 2024 08:17
@b6g
Copy link
Contributor Author

b6g commented Nov 27, 2024

The client-go PR is merged and go.mod is updated. The PR is ready for review. PTAL Thanks!

@@ -109,7 +109,7 @@ require (
github.com/tdakkota/asciicheck v0.2.0
Copy link
Member

Choose a reason for hiding this comment

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

Please run the make bazel_preapre and upload the dependencies.

@b6g
Copy link
Contributor Author

b6g commented Nov 27, 2024

Some tests failed with

Was it because the client-go PR was just merged and it takes time to create http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip?

@b6g b6g force-pushed the b6g/tsinvariant1 branch from 1af9227 to ef63538 Compare November 27, 2024 18:50
@b6g
Copy link
Contributor Author

b6g commented Nov 27, 2024

Some tests failed with

Was it because the client-go PR was just merged and it takes time to create http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip?

The error was,

Error in download_and_extract: java.io.IOException: Error downloading [http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip, http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip, https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip, https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip] to /root/.cache/bazel/_bazel_root/37ff7b0eddea115f60ab9f853788d7f5/external/com_github_tikv_client_go_v2/temp12921244511850196136/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip: GET returned 404 Not Found

@b6g
Copy link
Contributor Author

b6g commented Nov 28, 2024

/test build

Copy link

tiprow bot commented Nov 28, 2024

@b6g: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test build

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@b6g
Copy link
Contributor Author

b6g commented Nov 28, 2024

/retest

@b6g
Copy link
Contributor Author

b6g commented Nov 29, 2024

Some tests failed with

Was it because the client-go PR was just merged and it takes time to create http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip?

How can I update the client-go version? I tried,

go get github.com/tikv/client-go/v2@89643b0e8c9ee8cbd0fce4f264a8765c5665db17

But these tests failed.

@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

Some tests failed with
Was it because the client-go PR was just merged and it takes time to create http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241127071526-89643b0e8c9e.zip?

How can I update the client-go version? I tried,

go get github.com/tikv/client-go/v2@89643b0e8c9ee8cbd0fce4f264a8765c5665db17

But these tests failed.

I has uploaded it. you can try the unit test again.

@hawkingrei
Copy link
Member

BTW, Can you sync your code with master ?

@b6g b6g force-pushed the b6g/tsinvariant1 branch from ef63538 to d8cf419 Compare December 5, 2024 07:19
@b6g
Copy link
Contributor Author

b6g commented Dec 7, 2024

BTW, Can you sync your code with master ?

Will do. I am fixing the broken unittests.

@b6g b6g force-pushed the b6g/tsinvariant1 branch from d8cf419 to 3ec86a7 Compare December 7, 2024 16:37
Copy link

ti-chi-bot bot commented Dec 7, 2024

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests

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

📖 For more info, you can check the "Contribute Code" section in the development guide.

@b6g
Copy link
Contributor Author

b6g commented Dec 7, 2024

The unittests are fixed. PTAL

@b6g
Copy link
Contributor Author

b6g commented Dec 10, 2024

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/needs-tests-checked ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server: enhance the ts check considering commit timestamp
3 participants