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

add timeout for gs.GracefulStop #813

Merged
merged 4 commits into from
Nov 20, 2019
Merged

add timeout for gs.GracefulStop #813

merged 4 commits into from
Nov 20, 2019

Conversation

IANTHEREAL
Copy link
Collaborator

What problem does this PR solve?

sometime pump would block at gs.GracefulStop when it exits, we still don't know the specific reason, but we don't need to wait for GRPC service exited, it's safe.

What is changed and how it works?

add a timeout mechanism to give up waiting for the goroutine to exit

Check List

Tests

  • Unit test

@IANTHEREAL
Copy link
Collaborator Author

/run-all-tests

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/util/util.go Outdated
exited := make(chan struct{})
go func() {
defer func() {
log.Info("goroutine exit bt itself (with GoAndAbortGoroutine help)", fName)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does bt mean?

pkg/util/util.go Outdated
}()

select {
case <-time.After((timeout)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
case <-time.After((timeout)):
case <-time.After(timeout):

pkg/util/util.go Outdated
@@ -280,3 +280,22 @@ func AdjustDuration(v *time.Duration, defValue time.Duration) {
*v = defValue
}
}

// GoAndAbortGoroutine creates a goroutine to run fn, and then gives up waiting for the goroutine to exit When it timeouts
func GoAndAbortGoroutine(name string, fn func(), timeout time.Duration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe WaitUntilTimeout is a better name?

Copy link
Contributor

@suzaku suzaku left a comment

Choose a reason for hiding this comment

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

LGTM

@IANTHEREAL
Copy link
Collaborator Author

/run-all-tests

@suzaku
Copy link
Contributor

suzaku commented Nov 20, 2019

/run-integration-tests tidb=release-3.0

@sre-bot
Copy link

sre-bot commented Nov 20, 2019

cherry pick to release-3.0 in PR #817

@sre-bot
Copy link

sre-bot commented Nov 20, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link

sre-bot commented Nov 22, 2019

cherry pick to release-3.1 in PR #824

IANTHEREAL pushed a commit that referenced this pull request Nov 22, 2019
* add timeout for gs.GracefulStop
IANTHEREAL added a commit that referenced this pull request Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants