-
Notifications
You must be signed in to change notification settings - Fork 727
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
*: enable errcheck for server/*.go except server/api #8317
Conversation
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
pkg/replication/replication_mode.go
Outdated
@@ -232,46 +232,44 @@ func (m *ModeManager) loadDRAutoSync() error { | |||
return nil | |||
} | |||
|
|||
func (m *ModeManager) drSwitchToAsyncWait(availableStores []uint64) error { | |||
func (m *ModeManager) drSwitchToAsyncWait(availableStores []uint64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller always ignored this error, and all errors were logged within the function, so I removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the tests will check the return value of drSwitchToAsync
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I will revert it for the test
pkg/replication/replication_mode.go
Outdated
} | ||
|
||
func (m *ModeManager) drSwitchToAsync(availableStores []uint64) error { | ||
func (m *ModeManager) drSwitchToAsync(availableStores []uint64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
pkg/mcs/registry/registry.go
Outdated
l.RegisterRESTHandler(h) | ||
log.Info("restful API service already registered", zap.String("prefix", prefix), zap.String("service-name", name)) | ||
if err := l.RegisterRESTHandler(h); err != nil { | ||
log.Error("register REST handler failed", zap.String("prefix", prefix), zap.String("service-name", name), zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error("register REST handler failed", zap.String("prefix", prefix), zap.String("service-name", name), zap.Error(err)) | |
log.Error("register restful API service failed", zap.String("prefix", prefix), zap.String("service-name", name), zap.Error(err)) |
@@ -100,7 +100,9 @@ func (se *StorageEndpoint) LoadMinServiceGCSafePoint(now time.Time) (*ServiceSaf | |||
} | |||
|
|||
if ssp.ExpiredAt < now.Unix() { | |||
se.Remove(key) | |||
if err := se.Remove(key); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to return the error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in c01b053
s.limit.WaitN(ctx, resp.Size()) | ||
if err := s.limit.WaitN(ctx, resp.Size()); err != nil { | ||
log.Error("failed to wait rate limit", errs.ZapError(err)) | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to return an error here.
After checking the source code, there are two types of errors that WaitN returns, fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, burst)
and context errors.
- For the former. If
resp.Size()
exceeds the burst, then continuing to loop will still result in an error becauseresp.Size
will keep increasing. In this case, the error won't be thrown, but adding logs will keep printing out, and the client may never receiveresp
. Unless we can guarantee that withinmaxSyncRegionBatchSize
, resp.Size will never exceed the burst (20MiB). - For the latter, it doesn't matter, because there is a
select ctx.Done()
inside the loop.
If we can't guarantee that the information of maxSyncRegionBatchSize regions is definitely less than 20MiB, it's best to check if resp.Size is close to 20MiB before continuing at L275.
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
l.RegisterRESTHandler(h) | ||
log.Info("restful API service registered successfully", zap.String("prefix", prefix), zap.String("service-name", name)) | ||
if err := l.RegisterRESTHandler(h); err != nil { | ||
log.Error("register restful API service failed", zap.String("prefix", prefix), zap.String("service-name", name), zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is best to distinguish it from line 86.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line numbers of log will be automatically differentiated, or do you have any suggestions on how to modify the log content?
@@ -49,7 +49,7 @@ type dummyRestService struct{} | |||
|
|||
func (dummyRestService) ServeHTTP(w http.ResponseWriter, _ *http.Request) { | |||
w.WriteHeader(http.StatusNotImplemented) | |||
w.Write([]byte("not implemented")) | |||
w.Write([]byte("not implemented")) // nolint:errcheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. Prefer using _ = w.Write([]byte("not implemented"))
.
@@ -53,7 +53,7 @@ type dummyRestService struct{} | |||
|
|||
func (dummyRestService) ServeHTTP(w http.ResponseWriter, _ *http.Request) { | |||
w.WriteHeader(http.StatusNotImplemented) | |||
w.Write([]byte("not implemented")) | |||
w.Write([]byte("not implemented")) // nolint:errcheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Signed-off-by: okJiang <819421878@qq.com>
if err := stream.Send(resps); err != nil { | ||
return errors.WithStack(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether it is on purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed forgot to consider error handling previously.
Signed-off-by: okJiang <819421878@qq.com>
/merge |
@JmPotato: We have migrated to builtin 👉 Please use
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. |
/approve |
@okJiang: Your PR was out of date, I have automatically updated it for you. 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. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JmPotato, niubell, rleungx 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 |
What problem does this PR solve?
Issue Number: Ref #1919
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note