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

pkg/errctx, *: use errctx to handle TruncateError #48970

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Nov 28, 2023

What problem does this PR solve?

Issue Number: close #48919

Problem Summary:

I tried to use errctx to handle the TruncateError in this PR. The comment in #48919 (comment) is useful for reading this PR.

What changed and how does it work?

  1. Remove the flags related with TruncateError in types.Context, and also remove the function HandleTruncate.
  2. Replace every HandleTruncate with HandleError.
  3. Use HandleError to handle the errors if needed, after calling to the functions inside types.

The problem is that, we don't know when it's needed to call HandleError. Even the TruncateErr is not always handled inside types package (previously). Some of these errors will return without considering TruncateAsWarning... And the original logic depends on this behavior. It's impossible to tell or predict the "correct" behavior of the types package before this PR.

With this PR, I made the behavior of the functions in types clearer. These functions will always return a valid result even if an error is returned. For example, Compare float with string will fail if the string cannot be parsed as a float. Previously, Compare will always return 0 in this situation. Now, it will compare the float with the truncated value and give a result.

I'm not confident that the current behavior is 100% same with the original one, but at least it passed all test cases and we can have a clearer mind when we are handling errors/warnings in the future.

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.

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@YangKeao YangKeao added the release-note-none Denotes a PR that doesn't merit a release note. label Nov 28, 2023
@ti-chi-bot ti-chi-bot bot added 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 Nov 28, 2023
@YangKeao YangKeao force-pushed the fix-48919 branch 2 times, most recently from 3af0f5b to 6ad1e12 Compare November 28, 2023 11:24
Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Attention: Patch coverage is 80.53571% with 109 lines in your changes missing coverage. Please review.

Project coverage is 72.5225%. Comparing base (ef02d72) to head (60c6173).
Report is 2231 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48970        +/-   ##
================================================
+ Coverage   70.9932%   72.5225%   +1.5292%     
================================================
  Files          1368       1391        +23     
  Lines        403988     411180      +7192     
================================================
+ Hits         286804     298198     +11394     
+ Misses        97214      94175      -3039     
+ Partials      19970      18807      -1163     
Flag Coverage Δ
integration 43.7192% <80.5357%> (?)
unit 70.9813% <ø> (-0.0119%) ⬇️

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 48.3667% <0.0000%> (-4.6156%) ⬇️

@YangKeao YangKeao force-pushed the fix-48919 branch 10 times, most recently from 8cbbd40 to 8c9b0e8 Compare November 29, 2023 08:46
@YangKeao
Copy link
Member Author

/retest

@pingcap pingcap deleted a comment from ti-chi-bot bot Nov 29, 2023
@pingcap pingcap deleted a comment from tiprow bot Nov 29, 2023
@YangKeao YangKeao marked this pull request as ready for review November 29, 2023 09:33
@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 Nov 29, 2023
@YangKeao YangKeao force-pushed the fix-48919 branch 4 times, most recently from 193dbc5 to deec22e Compare November 30, 2023 04:32
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
@YangKeao
Copy link
Member Author

/retest

1 similar comment
@YangKeao
Copy link
Member Author

/retest

Copy link

ti-chi-bot bot commented Nov 30, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lcwangchao
Once this PR has been reviewed and has the lgtm label, please assign benjamin2037, windtalker for approval. For more information see the Kubernetes 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

ti-chi-bot bot commented Nov 30, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-30 07:33:23.808053628 +0000 UTC m=+1080832.473279827: ☑️ agreed by lcwangchao.

@YangKeao YangKeao marked this pull request as draft November 30, 2023 08:52
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 30, 2023
@lcwangchao lcwangchao self-requested a review December 1, 2023 07:41
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2023
Copy link

ti-chi-bot bot commented Dec 8, 2023

PR needs rebase.

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.

Copy link

ti-chi-bot bot commented Sep 4, 2024

@YangKeao: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build 60c6173 link true /test build
idc-jenkins-ci-tidb/check_dev 60c6173 link true /test check-dev
idc-jenkins-ci-tidb/check_dev_2 60c6173 link true /test check-dev2
idc-jenkins-ci-tidb/mysql-test 60c6173 link true /test mysql-test
idc-jenkins-ci-tidb/unit-test 60c6173 link true /test unit-test
pull-integration-ddl-test 60c6173 link true /test pull-integration-ddl-test
pull-mysql-client-test 60c6173 link true /test pull-mysql-client-test
pull-br-integration-test 60c6173 link true /test pull-br-integration-test
pull-lightning-integration-test 60c6173 link true /test pull-lightning-integration-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-1-more-lgtm needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

migrate handling truncate error from typectx to errctx
2 participants