Skip to content

fix: avoid holding server map lock - #6479

Merged
jedevc merged 1 commit into
dagger:mainfrom
jedevc:avoid-server-mu-long-lock
Jan 24, 2024
Merged

jedevc merged 1 commit into
dagger:mainfrom
jedevc:avoid-server-mu-long-lock

Conversation

@jedevc

@jedevc jedevc commented Jan 23, 2024

Copy link
Copy Markdown
Contributor

We should avoid holding the server map lock for any long period of time. This should help to prevent a total deadlock in the case where a rogue server holds the lock for too long during shutdown (for currently unknown reasons).

By reducing our usage of the global map lock to only simple operations that won't block, we ensure that this rogue server doesn't block every operation on the controller.

However, because of this refactor, we need to introduce a more precise per-server-id lock. This lock is used to prevent multiple incoming session requests from spawning multiple servers for the same ID in parallel.

@jedevc
jedevc requested review from sipsma and vito January 23, 2024 12:09
Comment thread engine/server/buildkitcontroller.go Outdated

@jedevc jedevc Jan 23, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jedevc jedevc mentioned this pull request Jan 23, 2024

@sipsma sipsma left a comment

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.

LGTM! Just a naming nit, not a blocker

Comment thread engine/server/buildkitcontroller.go Resolved
We should avoid holding the server map lock for any long period of time.
This should help to prevent a total deadlock in the case where a rogue
server holds the lock for too long during shutdown (for currently
unknown reasons).

By reducing our usage of the global map lock to only simple operations
that won't block, we ensure that this rogue server doesn't block every
operation on the controller.

However, because of this refactor, we need to introduce a more precise
per-server-id lock. This lock is used to prevent multiple incoming
session requests from spawning multiple servers for the same ID in
parallel.

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc force-pushed the avoid-server-mu-long-lock branch from 5e00e61 to bdaf692 Compare January 24, 2024 11:45
@jedevc
jedevc merged commit 2aefe55 into dagger:main Jan 24, 2024
@jedevc
jedevc deleted the avoid-server-mu-long-lock branch January 24, 2024 15:04
jedevc added a commit to jedevc/dagger that referenced this pull request Jan 25, 2024
This reverts commit 2aefe55.

Because otherwise it's harder to repro.
@gerhard gerhard added this to the v0.9.8 milestone Jan 26, 2024
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