Skip to content

fix pilot ads goroutine leak and memory leak#10862

Closed
pxzero wants to merge 3 commits intoistio:release-1.1from
pxzero:release-1.1
Closed

fix pilot ads goroutine leak and memory leak#10862
pxzero wants to merge 3 commits intoistio:release-1.1from
pxzero:release-1.1

Conversation

@pxzero
Copy link
Copy Markdown

@pxzero pxzero commented Jan 10, 2019

For #10822
commit PR to branch release 1.1

@istio-testing
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pxzero
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: vadimeisenbergibm

If they are not already assigned, you can assign the PR to them by writing /assign @vadimeisenbergibm in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@istio-testing
Copy link
Copy Markdown
Collaborator

Hi @pxzero. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

reqChannel <- req
select {
case <-controlChannel:
adsLog.Errorf("ADS: %q %s stream has closed", con.PeerAddr, con.ConID)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it indeed an error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function doesn't return any status, so I'd assume that even if it was an error, it could be logged by the code that caused the channel to be closed and here we'd simply return.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agree ! simply return is enough

<-reqChannel
}
}()
go receiveThread(con, reqChannel, &receiveError, controlChannel)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of passing another controlChannel why not simply close the reqChannel and catch this on the other side?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

emm...i'm a fresher to golang . i will try it.
thanks for reply

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes , i have try code like this. It is simply but not easy to understand the mean of panic recover. maybe using a control channel can be more readable ?

func receiveThread(con *XdsConnection, reqChannel chan *xdsapi.DiscoveryRequest, errP *error) {
	defer close(reqChannel) // indicates close of the remote side.
	defer func() {
		if r := recover(); r != nil {
			err, ok := r.(error)
			if ok {
				errP = &err
			}
		}
	}()
	for {
		req, err := con.stream.Recv()
		if err != nil {
			if status.Code(err) == codes.Canceled || err == io.EOF {
				con.mu.RLock()
				adsLog.Infof("ADS: %q %s terminated %v", con.PeerAddr, con.ConID, err)
				con.mu.RUnlock()
				return
			}
			*errP = err
			adsLog.Errorf("ADS: %q %s terminated with errors %v", con.PeerAddr, con.ConID, err)
			totalXDSInternalErrors.Add(1)
			return
		}
		reqChannel <- req
	}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's already con.doneChannel that's closed when StreamAggregatedResources returns, seems you could use that in receiveThread. Seems simpler and cleaner than abusing panic recovery.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

greet . use doneChannel is awesome!

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Jan 12, 2019
@istio-testing
Copy link
Copy Markdown
Collaborator

@pxzero: PR needs rebase.

Details

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.

@stale
Copy link
Copy Markdown

stale bot commented Jan 27, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@ymesika ymesika closed this Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR needs to be rebased before being merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants