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

*: milisecond test and infoschema fix #24820

Merged
merged 11 commits into from
May 24, 2021
Merged

Conversation

xhebox
Copy link
Contributor

@xhebox xhebox commented May 21, 2021

What problem does this PR solve?

Issue Number: close #24812

Problem Summary: Failed because of time prec. While fixing the problem, I found that when commit is executed, TxnCtx.InfoSchema is not refreshed, it is lazily refreshed. Then sessionVars.GetInfoSchema() will return the old infoschema after commit.

Later commits will hopefully remove the usage of dom.InfoSchema() and refine TxnCtx. But for now, let us merge this PR first.

What is changed and how it works?

What's Changed:

  1. Add check vars.TxnCtx != nil && vars.TxnCtx.IsExplicit for GetInfoSchema(). Now it will not return the old infoschema after commit, but will still return nil.
  2. Add domain.GetDomain(sctx).InfoSchema() for GetInfoSchema() to return the latest commit after commit. But there is a circular dependency loop, it is moved from a getter of sessionVars to a method of sessionctx.Context.
  3. Remove builder.Request.SchemaVar = is.SchemaMetaVersion() in SetFromSessionVars and add builder.Request.SchemaVar = is.SchemaMetaVersion() in SetFromInfoSchema. Several SetFromInfoSchema was added to ensure infoschema is set correctly.

Check List

Tests

  • Unit test
  • Integration test

Release note

  • No release note

@xhebox xhebox requested review from a team as code owners May 21, 2021 07:01
@xhebox xhebox requested review from qw4990 and removed request for a team May 21, 2021 07:01
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 21, 2021
Comment on lines -234 to -237
// infoschema maybe null for tests
if is, ok := e.ctx.GetSessionVars().GetInfoSchema().(infoschema.InfoSchema); ok {
reqBuilder.SetFromInfoSchema(is)
}
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 part of logic is not the same as before? nil interface should be handled.

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 thought GetInfoSchema will always return something. I did not expect that domain.InfoSchema() will return nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Now request builder will check it by is, ok := emptyInterce.(InfoSchema).

@purelind
Copy link
Contributor

/run-build

@zhouqiang-cl
Copy link
Contributor

/run-all-tests

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 21, 2021
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 21, 2021
@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

OK, a mistake. Looks like IsExplicit can not always be updated.... It is more like a one-shot variable. I've switched to GetStatusFlag().
/run-all-tests

@purelind
Copy link
Contributor

/run-build

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 21, 2021
@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

OK.. Got another panic and fixed. So planner relies on that snapshot infoschema for testing, and I must provide a partial mock..

@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

/run-all-tests

1 similar comment
@purelind
Copy link
Contributor

/run-all-tests

@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

/run-integration-common-test

@purelind
Copy link
Contributor

/run-all-tests

@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

Why trigger all tests again and again? From the log, the error is reported by tidb-test/sqllogic_test/main.go

@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

/run-all-tests tidb-test=pr/1195

@purelind
Copy link
Contributor

Why trigger all tests again and again? From the log, the error is reported by tidb-test/sqllogic_test/main.go

CI just upgrade go version from 1.13 to 1.16.4. Here we want to check again

@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

/run-sqllogic-test-1 tidb-test=pr/1195

1 similar comment
@xhebox
Copy link
Contributor Author

xhebox commented May 21, 2021

/run-sqllogic-test-1 tidb-test=pr/1195

@xhebox
Copy link
Contributor Author

xhebox commented May 24, 2021

/run-integration-common-test

1 similar comment
@xhebox
Copy link
Contributor Author

xhebox commented May 24, 2021

/run-integration-common-test

@nolouch nolouch removed sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels May 24, 2021
@nolouch
Copy link
Member

nolouch commented May 24, 2021

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • nolouch

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 24, 2021
@nolouch nolouch added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels May 24, 2021
@nolouch
Copy link
Member

nolouch commented May 24, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

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.

@xhebox
Copy link
Contributor Author

xhebox commented May 24, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 2c131aa

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 24, 2021
// So we give a convenience for that.
// FIXME: remove this interface
type InfoschemaMetaVersion interface {
SchemaMetaVersion() int64
Copy link
Contributor

Choose a reason for hiding this comment

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

For interface used as a tool to avoid circular, we can put it in the util package.
But for this, it's ok.

@AilinKid
Copy link
Contributor

/lgtm

@JmPotato
Copy link
Member

/run-all-tests

@xhebox
Copy link
Contributor Author

xhebox commented May 24, 2021

/merge

@ti-chi-bot
Copy link
Member

@xhebox: 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
component/expression sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/XL Denotes a PR that changes 500-999 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.

TestStalenessTransactionSchemaVer is failed
8 participants