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

types, *: move truncate flags to the types context #47522

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

YangKeao
Copy link
Member

What problem does this PR solve?

Issue Number: close #47511

What is changed and how it works?

Move the IgnoreTruncateErr and TruncateAsWarning flags from the stmtctx to types.Context flags.

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.

These refractors are covered by existing tests.

Release note

None

@YangKeao YangKeao added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 10, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 10, 2023
@YangKeao
Copy link
Member Author

/test all

@tiprow
Copy link

tiprow bot commented Oct 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@YangKeao YangKeao force-pushed the fix-47511 branch 2 times, most recently from 12011de to 6b8465c Compare October 10, 2023 12:32
@YangKeao YangKeao force-pushed the fix-47511 branch 15 times, most recently from 153b1d8 to b75eacd Compare October 11, 2023 13:53
@YangKeao YangKeao marked this pull request as ready for review October 11, 2023 14:58
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 11, 2023
@YangKeao YangKeao requested review from lcwangchao and xhebox October 12, 2023 03:19
@YangKeao YangKeao force-pushed the fix-47511 branch 2 times, most recently from 9c98e8c to 57b1ee4 Compare October 16, 2023 06:09
@YangKeao
Copy link
Member Author

/retest

@YangKeao YangKeao force-pushed the fix-47511 branch 3 times, most recently from 0d4c3f7 to 44b4fa9 Compare October 16, 2023 08:15
@YangKeao
Copy link
Member Author

/retest

br/pkg/lightning/backend/tidb/tidb.go Outdated Show resolved Hide resolved
pkg/executor/executor.go Outdated Show resolved Hide resolved
pkg/executor/executor.go Outdated Show resolved Hide resolved
pkg/executor/executor.go Outdated Show resolved Hide resolved
pkg/executor/executor.go Outdated Show resolved Hide resolved
}

ctx := typectx.NewContext(typectx.StrictFlags, time.UTC, func(err error) {
logutil.BgLogger().Warn("append a warnings without proper statement context", zap.Error(err))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this happen in a production environment? If it is true, I think we'd better not warn it. If not , I think it's better to create a context like this:

ctx := typectx.NewContext(typectx.StrictFlags, time.UTC, func(err error) { assert(false) })

So that we can see the warning function is called by mistake

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the best way is to forbid all nil arguments of stmtctx.StatementContext. But I'm not sure it is practice practical now

Copy link
Member Author

Choose a reason for hiding this comment

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

Will this happen in a production environment?

Yes, now many functions in types is passed with nil statement context (some of them have been replaced by DefaultNoWarningContext, but there are still some of them which will need to be changed in the future with our refractors).

I agree not to warn. I'll return DefaultNoWarningContext directly in this function.

@YangKeao YangKeao force-pushed the fix-47511 branch 2 times, most recently from 7033a2c to c0eb810 Compare October 16, 2023 10:23
@YangKeao YangKeao requested a review from lcwangchao October 16, 2023 15:32
Copy link
Collaborator

@lcwangchao lcwangchao 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

pkg/executor/coprocessor.go Outdated Show resolved Hide resolved
@lcwangchao
Copy link
Collaborator

/LGTM

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 17, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 17, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-13 06:53:13.836963222 +0000 UTC m=+1380791.424073367: ☑️ agreed by xhebox.
  • 2023-10-17 03:56:08.731369497 +0000 UTC m=+1715766.318479642: ☑️ agreed by lcwangchao.

@lcwangchao
Copy link
Collaborator

/approve

@YangKeao
Copy link
Member Author

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, lcwangchao, xhebox, XuHuaiyu

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot bot added the approved label Oct 18, 2023
@YangKeao
Copy link
Member Author

/retest

1 similar comment
@YangKeao
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 3ef01b5 into pingcap:master Oct 18, 2023
wuhuizuo pushed a commit to wuhuizuo/tidb that referenced this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use truncated related flags to handle truncte cases in types package
5 participants