[ https://issues.apache.org/jira/browse/SCB-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16304438#comment-16304438 ]
ASF GitHub Bot commented on SCB-128: ------------------------------------ little-cui closed pull request #231: SCB-128 Optimize lease.go URL: https://github.com/apache/incubator-servicecomb-service-center/pull/231 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/server/core/backend/store/lease.go b/server/core/backend/store/lease.go index 04a2ff9..2124b70 100644 --- a/server/core/backend/store/lease.go +++ b/server/core/backend/store/lease.go @@ -39,31 +39,31 @@ func (lat *LeaseAsyncTask) Key() string { return lat.key } -func (lat *LeaseAsyncTask) Do(ctx context.Context) (err error) { +func (lat *LeaseAsyncTask) Do(ctx context.Context) error { lat.StartTime = time.Now() - lat.TTL, err = backend.Registry().LeaseRenew(ctx, lat.LeaseID) + lat.TTL, lat.err = backend.Registry().LeaseRenew(ctx, lat.LeaseID) lat.EndTime = time.Now() - if err == nil { - lat.err = err + if lat.err == nil { util.LogNilOrWarnf(lat.CreateTime, "renew lease %d(rev: %s, run: %s), key %s", lat.LeaseID, lat.CreateTime.Format(TIME_FORMAT), lat.StartTime.Format(TIME_FORMAT), lat.Key()) - return + return nil } - util.Logger().Errorf(err, "[%s]renew lease %d failed(rev: %s, run: %s), key %s", + util.Logger().Errorf(lat.err, "[%s]renew lease %d failed(rev: %s, run: %s), key %s", time.Now().Sub(lat.CreateTime), lat.LeaseID, lat.CreateTime.Format(TIME_FORMAT), lat.StartTime.Format(TIME_FORMAT), lat.Key()) - if _, ok := err.(errorsEx.InternalError); !ok { - lat.err = err - return + if _, ok := lat.err.(errorsEx.InternalError); ok { + lat.err = nil } - return nil + + // lease not found. + return lat.err } func (lat *LeaseAsyncTask) Err() error { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Heartbeat failure when etcd has no leader > ----------------------------------------- > > Key: SCB-128 > URL: https://issues.apache.org/jira/browse/SCB-128 > Project: Apache ServiceComb > Issue Type: Bug > Components: Service-Center > Reporter: little-cui > -- This message was sent by Atlassian JIRA (v6.4.14#64029)