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

infoschema: fix panic for TableByID when table id is negative #52016

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

lcwangchao
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #52012

What changed and how does it work?

tableBucketIdx should always return an non-negative value.

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.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

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

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 22, 2024
Copy link

tiprow bot commented Mar 22, 2024

Hi @lcwangchao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

pkg/infoschema/builder.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 22, 2024
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Merging #52016 (a00db6d) into master (1549ea6) will decrease coverage by 16.0777%.
Report is 4 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52016         +/-   ##
=================================================
- Coverage   70.7412%   54.6636%   -16.0777%     
=================================================
  Files          1486       1597        +111     
  Lines        439485     609186     +169701     
=================================================
+ Hits         310897     333003      +22106     
- Misses       109161     253072     +143911     
- Partials      19427      23111       +3684     
Flag Coverage Δ
integration 36.6007% <21.4285%> (?)
unit 70.4511% <100.0000%> (-0.1073%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.5170% <ø> (+5.6745%) ⬆️

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 22, 2024
Copy link

ti-chi-bot bot commented Mar 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-22 03:40:38.846919704 +0000 UTC m=+1607265.869166090: ☑️ agreed by tiancaiamao.
  • 2024-03-22 03:55:31.316626395 +0000 UTC m=+1608158.338872783: ☑️ agreed by AilinKid.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 25, 2024
@lcwangchao lcwangchao force-pushed the fix_52012 branch 2 times, most recently from 1c53d57 to d40e09c Compare March 25, 2024 11:29
@lcwangchao
Copy link
Collaborator Author

/retest

Copy link

tiprow bot commented Mar 25, 2024

@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@lcwangchao lcwangchao force-pushed the fix_52012 branch 3 times, most recently from b33ddc6 to bb899a3 Compare March 25, 2024 14:01
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

@zimulala has some ideas to sync

@@ -970,9 +971,10 @@ func NewBuilder(r autoid.Requirement, factory func() (pools.Resource, error), in
}

func tableBucketIdx(tableID int64) int {
intest.Assert(tableID > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this tableID > 0 be false in the test scenario? If so, whether it is possible to encounter real scenes. If not, is the test unnecessary?

Copy link
Collaborator Author

@lcwangchao lcwangchao Mar 27, 2024

Choose a reason for hiding this comment

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

We found tableID <= 0 in some test cases but they are handled before tableBucketIdx. However, adding assert here for two propose:

  • Provide a more clear reason for the failed test even if it would also fail without the assert function. The assert function is a more straightforward way to check the constraints.

  • This assert also checks tableID should not be 0. It may not fail if some codes building infoschema with an zero id table.

Copy link

ti-chi-bot bot commented Mar 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, BornChanger, tiancaiamao, zimulala

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 Mar 27, 2024
@ti-chi-bot ti-chi-bot bot merged commit b96f081 into pingcap:master Mar 27, 2024
24 of 25 checks passed
@lcwangchao lcwangchao deleted the fix_52012 branch March 27, 2024 06:27
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic log for some http API with negative table id
5 participants