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

controller: avoid the invalid nil pointer #6486

Merged
merged 5 commits into from
May 19, 2023
Merged

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented May 18, 2023

What problem does this PR solve?

Issue Number: Close #6485

What is changed and how does it work?

controller: avoid the invalid nil pointer

Check List

Tests

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 18, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • JmPotato

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels May 18, 2023
@ti-chi-bot ti-chi-bot bot requested review from lhy1024 and Yisaer May 18, 2023 10:34
@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed do-not-merge/needs-triage-completed labels May 18, 2023
Signed-off-by: nolouch <nolouch@gmail.com>
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Patch coverage: 40.42% and project coverage change: +0.04 🎉

Comparison is base (6f6bf01) 75.03% compared to head (08db261) 75.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6486      +/-   ##
==========================================
+ Coverage   75.03%   75.07%   +0.04%     
==========================================
  Files         410      410              
  Lines       41823    41858      +35     
==========================================
+ Hits        31380    31424      +44     
+ Misses       7698     7687      -11     
- Partials     2745     2747       +2     
Flag Coverage Δ
unittests 75.07% <40.42%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
client/resource_group/controller/model.go 58.33% <7.14%> (-15.36%) ⬇️
client/client.go 62.67% <88.23%> (+3.42%) ⬆️
client/keyspace_client.go 65.15% <100.00%> (+1.51%) ⬆️
tests/integrations/mcs/testutil.go 96.93% <100.00%> (ø)

... and 31 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch nolouch requested review from JmPotato, CabinfeverB and Connor1996 and removed request for Yisaer and lhy1024 May 18, 2023 11:14
client/resource_group/controller/model.go Outdated Show resolved Hide resolved
return group.RawResourceSettings.IoWrite
}
return nil
}

func add(custom1 *rmpb.Consumption, custom2 *rmpb.Consumption) {
if custom1 == nil || custom2 == nil {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it reasonable to return the non-nil one and only return nothing when both are 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.

I'm not getting your point. It's reasonable to return once it has nil in here I think.

Copy link
Member

Choose a reason for hiding this comment

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

For example, if custom1 is nil and custom2 is not, we can simply return custom2 instead of a nil value.

Copy link
Member

Choose a reason for hiding this comment

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

It means if custom1 is nil, we can return custom2

Copy link
Contributor Author

@nolouch nolouch May 19, 2023

Choose a reason for hiding this comment

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

There is some misunderstanding here. this function no return values, just exit the function call.

Copy link
Member

Choose a reason for hiding this comment

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

OK

Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch
Copy link
Contributor Author

nolouch commented May 19, 2023

PTAL @JmPotato @CabinfeverB @HuSharp

Copy link
Member

@CabinfeverB CabinfeverB left a comment

Choose a reason for hiding this comment

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

Is it possible nil consumption occur inKVCalculator?
rest LGTM.

Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch
Copy link
Contributor Author

nolouch commented May 19, 2023

KVCalculator

Done @CabinfeverB

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 19, 2023

@HuSharp: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

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.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 19, 2023
@ti-chi-bot ti-chi-bot bot removed the status/LGT1 Indicates that a PR has LGTM 1. label May 19, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT2 Indicates that a PR has LGTM 2. label May 19, 2023
@nolouch
Copy link
Contributor Author

nolouch commented May 19, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 19, 2023

@nolouch: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 19, 2023

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

Commit hash: 08db261

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 19, 2023
@ti-chi-bot ti-chi-bot bot merged commit 1613e22 into tikv:master May 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #6496.

@nolouch nolouch deleted the fix-panic branch May 19, 2023 11:51
ti-chi-bot bot pushed a commit that referenced this pull request May 19, 2023
ref #6485, close #6485, ref #6486

controller: avoid the invalid nil pointer

Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: nolouch <nolouch@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. release-note-none Denotes a PR that doesn't merit a release note. 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.

Hit connection running loop panic in tidb when do patrol check in serverless prod env
5 participants