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

executor: implement set transaction read only as of transaction #24766

Merged

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented May 19, 2021

Signed-off-by: yisaer disxiaofei@163.com

What problem does this PR solve?

Issue Number: ref #21094

What is changed and how it works?

Implement Set Transaction read only as of ..... statement.

Check List

Tests

  • Unit test

Release note

  • No release note

Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer requested a review from a team as a code owner May 19, 2021 13:30
@Yisaer Yisaer requested review from XuHuaiyu and removed request for a team May 19, 2021 13:30
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 19, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented May 19, 2021

/cc @xhebox

@ti-chi-bot ti-chi-bot requested a review from xhebox May 19, 2021 13:31
@github-actions github-actions bot added the sig/execution SIG execution label May 19, 2021

func (s *testStaleTxnSerialSuite) TestSetTransactionReadOnlyAsOf(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec(`SET TRANSACTION READ ONLY as of timestamp '2021-04-21 00:42:12'`)
Copy link
Member

Choose a reason for hiding this comment

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

Should support expression? our bound read is a function call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is already supported, the testcase updated.

Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 20, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2021
@xhebox
Copy link
Contributor

xhebox commented May 21, 2021

/lgtm

@ti-chi-bot
Copy link
Member

@xhebox: Thanks for your review. The bot only counts /lgtm from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

/lgtm

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 ti-community-infra/tichi repository.

@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from 97b2c43 to 7f7643f Compare May 21, 2021 05:34
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented May 21, 2021

/label sig/sql-infra

@ti-chi-bot
Copy link
Member

@Yisaer: The label(s) sig/sql-infra cannot be applied. These labels are supported: CHANGELOG, challenge-program, compatibility-breaker, contribution, correctness, first-time-contributor, good-first-issue, hacktoberfest, high-performance, hptc, need-more-info, needs-cherry-pick-3.0, needs-cherry-pick-3.1, needs-cherry-pick-4.0, needs-cherry-pick-5.0, proposal, release-note, require-LGT3, security, tools.

In response to this:

/label sig/sql-infra

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 ti-community-infra/tichi repository.

@Yisaer
Copy link
Contributor Author

Yisaer commented May 21, 2021

/sig sql-infra

@ti-chi-bot ti-chi-bot added the sig/sql-infra SIG: SQL Infra label May 21, 2021
Copy link
Member

@JmPotato JmPotato left a comment

Choose a reason for hiding this comment

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

The rest LGTM.

s.TxnReadTS = GoTimeToTS(t1)
return err
}

// GoTimeToTS converts a Go time to uint64 timestamp.
func GoTimeToTS(t time.Time) uint64 {
Copy link
Member

Choose a reason for hiding this comment

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

I think this function is duplicated with oracle.GoTimeToTS, maybe we should remove it and use the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

@Yisaer Yisaer requested a review from nolouch May 21, 2021 10:05
Signed-off-by: yisaer <disxiaofei@163.com>

fix test

Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from b320672 to 8e32482 Compare May 21, 2021 10:09
@xhebox
Copy link
Contributor

xhebox commented May 24, 2021

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 24, 2021
Comment on lines 577 to 578
e.ctx.GetSessionVars().SetInTxn(true)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you set it and return? To walk around s.ReadOnly part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

@@ -825,6 +825,13 @@ var defaultSysVars = []*SysVar{
}, GetSession: func(s *SessionVars) (string, error) {
return s.TxnScope.GetVarValue(), nil
}},
{Scope: ScopeSession, Name: TiDBTxnReadTS, Value: "", SetSession: func(s *SessionVars, val string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this sysvar exposed to users?

Copy link
Contributor Author

@Yisaer Yisaer May 25, 2021

Choose a reason for hiding this comment

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

I think it is ok to exposed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is, users may also use this variable to set read ts.

@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from 54308ce to 8085f85 Compare May 25, 2021 07:46
Signed-off-by: yisaer <disxiaofei@163.com>

address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

address the comment

Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from 8085f85 to ce2df75 Compare May 25, 2021 07:47
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2021
executor/simple.go Outdated Show resolved Hide resolved
Signed-off-by: yisaer <disxiaofei@163.com>

address the comment

Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from 2cb8e67 to 6c938a7 Compare May 25, 2021 07:56
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 25, 2021
@djshow832
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • djshow832
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 25, 2021
@djshow832
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 6c938a7

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 25, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the support_set_transaction_read_only_as_of branch from e2b4d41 to 3c465d0 Compare May 25, 2021 08:10
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label May 25, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented May 25, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 3c465d0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 25, 2021
@ti-chi-bot
Copy link
Member

@Yisaer: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants