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

Graceful shutdown the workers when reducing worker threads #1863

Merged
merged 9 commits into from
Nov 17, 2023

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Oct 31, 2023

#1855 introduced the data race even only migrating the non-blocking connections. For example:

T1: C0(connection) is running the command Config::Set on W0(worker) and C1 is running another command on W1. C0 got the exclusive lock for executing commands and C1 will wait for the lock inside ExecuteCommands.

T2: C0 migrates C1 to W0 after reducing the number of worker threads, but the ExecuteCommands function will continue executing after migrating. So both W0 and W1 will access the C1 at the same time.

To avoid this, I simply don't migrate the connection if it has any running command and delay to shut down the worker, so that old connections have a chance to complete the running command.

@git-hulk git-hulk force-pushed the graceful-shutdown-workers branch 2 times, most recently from 01df71b to 9b7e839 Compare November 2, 2023 12:49
@apache apache deleted a comment from sonarcloud bot Nov 2, 2023
@apache apache deleted a comment from sonarcloud bot Nov 2, 2023
@apache apache deleted a comment from sonarcloud bot Nov 2, 2023
@git-hulk git-hulk marked this pull request as ready for review November 2, 2023 16:53
@git-hulk git-hulk requested a review from PragmaTwice November 4, 2023 12:43
@git-hulk
Copy link
Member Author

git-hulk commented Nov 4, 2023

This PR opened before changing the sonar reconfigured, so just ignore it. cc @PragmaTwice

torwig
torwig previously approved these changes Nov 10, 2023
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

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

LGTM

@git-hulk git-hulk force-pushed the graceful-shutdown-workers branch from 29687c4 to e328917 Compare November 16, 2023 01:24
Copy link

sonarcloud bot commented Nov 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
2.8% 2.8% Duplication

@git-hulk git-hulk requested a review from torwig November 16, 2023 03:27
@git-hulk git-hulk merged commit a68f07e into apache:unstable Nov 17, 2023
30 checks passed
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.

3 participants