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

Fix a potential goroutine leak #114071

Merged
merged 1 commit into from
Dec 10, 2022
Merged

Fix a potential goroutine leak #114071

merged 1 commit into from
Dec 10, 2022

Conversation

Mskxn
Copy link
Contributor

@Mskxn Mskxn commented Nov 22, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

When the server stopped before timeout, the stopped <-true will be executed and in the select block, the first case will be chosen. This will lead to a hanging goroutine at line 111 because no receiver of timeout is left. Changing the timeout chan to a buffered one can fix it.

Which issue(s) this PR fixes:

Fixes #114070

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 22, 2022
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.26 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.26.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Tue Nov 22 09:29:40 UTC 2022.

@k8s-ci-robot k8s-ci-robot requested a review from jpbetz November 22, 2022 14:39
@k8s-ci-robot k8s-ci-robot added the area/release-eng Issues or PRs related to the Release Engineering subproject label Nov 22, 2022
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 22, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @Mskxn!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @Mskxn. Thanks for your PR.

I'm waiting for a kubernetes 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.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 22, 2022
@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 22, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Mskxn (5f94aa3ea45518e8f9a907fd01be9cd217b4e789)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 22, 2022
@aojea
Copy link
Member

aojea commented Nov 22, 2022

can you add a test demonstrating the problem?

@Mskxn
Copy link
Contributor Author

Mskxn commented Nov 23, 2022

Actually, it is very similar to #102637. I think TestMigrate in integration_test.go can trigger it with a leak checker like goleak which can detect partial goroutine leak

@fedebongio
Copy link
Contributor

/assign @aojea
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 29, 2022
@aojea
Copy link
Member

aojea commented Nov 29, 2022

/ok-to-test
/lgmt
/approve

Thanks

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 29, 2022
@aojea
Copy link
Member

aojea commented Nov 29, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 29, 2022
@aojea
Copy link
Member

aojea commented Nov 29, 2022

Actually, it is very similar to #102637. I think TestMigrate in integration_test.go can trigger it with a leak checker like goleak which can detect partial goroutine leak

yep, thanks for the clarification, I should have paid more attention

@@ -105,7 +105,7 @@ func (r *EtcdMigrateServer) Stop() error {
}
gracefulWait := time.Minute * 2
stopped := make(chan bool)
timedout := make(chan bool)
timedout := make(chan bool, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of that, instead of sending an item to a channel, we should simply close it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@wojtek-t
Copy link
Member

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 30, 2022
@wojtek-t wojtek-t self-assigned this Nov 30, 2022
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 30, 2022
@@ -108,7 +108,7 @@ func (r *EtcdMigrateServer) Stop() error {
timedout := make(chan bool)
go func() {
time.Sleep(gracefulWait)
timedout <- true
close(timedout)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wojtek-t
Copy link
Member

@Mskxn - please squash commits, one squashed, this LGTM

Close the channel instead of write to it to avoid hanging goroutine.
@Mskxn
Copy link
Contributor Author

Mskxn commented Nov 30, 2022

squashed and PTAL.

@wojtek-t
Copy link
Member

wojtek-t commented Dec 1, 2022

/lgtm
/approve

/hold cancel

/milestone v1.27

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 1, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Dec 1, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 1, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, Mskxn, wojtek-t

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2022
@dims
Copy link
Member

dims commented Dec 10, 2022

/retest

@k8s-ci-robot k8s-ci-robot merged commit 89f6cb3 into kubernetes:master Dec 10, 2022
@k8s-ci-robot k8s-ci-robot modified the milestones: v1.27, v1.26 Dec 10, 2022
@liggitt liggitt modified the milestones: v1.26, v1.27 Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Goroutine leak in EtcdMigrateServer
8 participants