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 rare deadlock in scanner.Stop #3818

Merged
merged 3 commits into from
Jan 20, 2023

Conversation

MichaelSnowden
Copy link
Contributor

What changed?
I modified the Stop() method of our scanners to cancel running attempts to start workflows.

Why?
I did this because it fixes a race condition which often occurs when the server is shutdown soon after starting. When the server is shutdown, the scanner may still be trying startWorkflow. This method utilizes an SDK client. However, when the server shutdown all of its services, it may shutdown the frontend handler before the scanner. As a result, all calls to the SDK client will fail, causing startWorkflow to fail. Currently, we retry startWorkflow a lot, so the scanner can currently enter a long-running retry loop. To fix this, we now cancel the retries as soon as the scanner is shutdown.

How did you test it?
I added a test case which simulates the setup described above.

Potential risks
We may see some more error logs about SDK requests being canceled when servers are started/stopped.

Is hotfix candidate?
No.

service/worker/scanner/scanner.go Outdated Show resolved Hide resolved
service/worker/scanner/scanner.go Outdated Show resolved Hide resolved
service/worker/scanner/scanner_test.go Outdated Show resolved Hide resolved
service/worker/scanner/scanner.go Outdated Show resolved Hide resolved
Co-authored-by: David Reiss <david@temporal.io>
@MichaelSnowden MichaelSnowden enabled auto-merge (squash) January 20, 2023 05:17
@MichaelSnowden MichaelSnowden merged commit e0081fd into master Jan 20, 2023
@MichaelSnowden MichaelSnowden deleted the snowden/fix-scanner-shutdown branch January 20, 2023 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants