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, util: update session to use new APIs #22652

Merged
merged 14 commits into from
Feb 19, 2021
Merged

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Feb 1, 2021

What problem does this PR solve?

Part of https://github.com/pingcap/tidb-test/issues/1152

Problem Summary:

This fixes the session package to use the new APIs. It is expected to be backward compatible and covered by existing tests.

The bootstrap tasks between versions were not updated, as I'm not sure they will be accurately covered by unit tests to detect regressions.

What is changed and how it works?

New API usage.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • None

Release note

  • No release note

Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

Rest LGTM

session/bench_test.go Outdated Show resolved Hide resolved
@@ -141,26 +141,7 @@ func removeStore(c *C, dbPath string) {

func exec(se Session, sql string, args ...interface{}) (sqlexec.RecordSet, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us eliminate this function as it is only used in mustExec.

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 take a look in a followup PR. For now it looks like we are not getting into Execute/ExecuteInternal in the tests.

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 3, 2021
session/tidb_test.go Outdated Show resolved Hide resolved
@tiancaiamao
Copy link
Contributor

Well, maybe we don't need to change all the test code, as long as it does not affect the removal of the deprecated API.

@morgo
Copy link
Contributor Author

morgo commented Feb 3, 2021

I've reverted the tests so that they are still using Execute per the current plan. We can take a look at fixing master after all the cherry picks are complete.

@tiancaiamao
Copy link
Contributor

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 Feb 5, 2021
ti-srebot
ti-srebot previously approved these changes Feb 5, 2021
@morgo
Copy link
Contributor Author

morgo commented Feb 5, 2021

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 5, 2021
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@morgo merge failed.

@morgo
Copy link
Contributor Author

morgo commented Feb 5, 2021

/run-unit-test

@tiancaiamao
Copy link
Contributor

Oh, I've met that kind of DATA RACE before...
ParseWithParams() called by multiple goroutines, and there is only one parser, thus the DATA RACE.

@xhebox
Copy link
Contributor

xhebox commented Feb 5, 2021

This time it's in another place rather than statistics

How do you think about creating a new session like:

func BootstrapSession(store kv.Storage) (*domain.Domain, error)
...
        se2, err := createSession(store)
        if err != nil {
                return nil, err
        }
        se3, err := createSession(store)
        if err != nil {
                return nil, err
        }
        // We should make the load bind-info loop before other loops which has internal SQL.
        // Because the internal SQL may access the global bind-info handler. As the result, the data race occurs here as the
        // LoadBindInfoLoop inits global bind-info handler.
        err = dom.LoadBindInfoLoop(se2, se3)
        if err != nil {
                return nil, err
        }

@@ -2644,22 +2633,26 @@ var builtinGlobalVariable = []string{

var (
loadCommonGlobalVarsSQLOnce sync.Once
loadCommonGlobalVarsSQL string
loadCommonGlobalVarsStmt ast.StmtNode
Copy link
Contributor

Choose a reason for hiding this comment

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

The DATA RACE is caused by here, in the test cases, multiple test case run loadCommonGlobalVariablesIfNeeded and they will use astNode.Accept(vistor) (which is not read-only operation) in statement rewriter.

@tiancaiamao
Copy link
Contributor

/run-all-tests
PTAL @xhebox @AilinKid

@morgo
Copy link
Contributor Author

morgo commented Feb 8, 2021

/run-all-tests

@morgo
Copy link
Contributor Author

morgo commented Feb 8, 2021

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@xhebox
Copy link
Contributor

xhebox commented Feb 19, 2021

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@morgo merge failed.

@xhebox
Copy link
Contributor

xhebox commented Feb 19, 2021

/run-tics-test

@xhebox
Copy link
Contributor

xhebox commented Feb 19, 2021

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot removed the status/LGT3 The PR has already had 3 LGTM. label Feb 19, 2021
@ti-srebot ti-srebot added the status/LGT4 The PR has already had 4 LGTM. label Feb 19, 2021
@bb7133 bb7133 merged commit 99d0b22 into pingcap:master Feb 19, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Feb 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #22804

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Feb 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0-rc in PR #22805

ti-chi-bot added a commit that referenced this pull request Feb 24, 2021
* cherry pick #22652 to release-5.0-rc

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix merge conflicts

* fix merge

* remove needless check

Co-authored-by: Morgan Tocker <tocker@gmail.com>
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT4 The PR has already had 4 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants