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

Release memoryStore locks before filter/apply #22918

Merged
merged 1 commit into from May 26, 2016

Conversation

tonistiigi
Copy link
Member

Rework memoryStore so that filters and apply run
on a cloned list of containers after the lock has
been released. This avoids possible deadlocks when
these filter/apply callbacks take locks for a
container.

Fixes #22732

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

Rework memoryStore so that filters and apply run
on a cloned list of containers after the lock has
been released. This avoids possible deadlocks when
these filter/apply callbacks take locks for a
container.

Fixes moby#22732

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@cpuguy83
Copy link
Member

Don't we still only have pointers to the containers? Should this be a copy of each container, or is the issue with the collection itself?

@tonistiigi
Copy link
Member Author

@cpuguy83 The problem is that the memoryStore lock is being held when the callbacks run and need container locks. On attach, the situation is opposite where container lock is already held and memoryStore lock is needed.

@estesp
Copy link
Contributor

estesp commented May 24, 2016

Nice @tonistiigi ; this will help with some of the issues I have been looking at lately around lock contention. Specific to @cpuguy83's Q, the lock on the memoryStore is to protect iteration over it from modification via add/remove. Making a copy of the list resolves that problem. Container locks still exist to protect container metadata and already have appropriate protections via the container lock, so no extra work needs to be done here.

@aaronlehmann
Copy link
Contributor

This could be a good use case for https://github.com/hashicorp/go-immutable-radix. Each change to the tree results in a new tree root, but all nodes except the parents of the changed node are shared by the new tree and the old tree. By using atomic pointer swaps to update the tree root, it's a good way to do cheap copy-on-write. This is how https://github.com/hashicorp/go-memdb works.

@bukzor
Copy link

bukzor commented May 25, 2016

This was your only failure:

02:45:51 ----------------------------------------------------------------------
02:45:51 FAIL: docker_cli_help_test.go:15: TestHelpTextVerify.pN52_github_com_docker_docker_integration_cli.DockerSuite
02:45:51 
02:45:51 docker_cli_help_test.go:137:
02:45:51     c.Fatal(err)
02:45:51 ... Error: Should not have a blank line on ["logs"]
02:45:51 

@cpuguy83
Copy link
Member

LGTM

1 similar comment
@estesp
Copy link
Contributor

estesp commented May 26, 2016

LGTM

@estesp estesp merged commit 67767db into moby:master May 26, 2016
@mlaventure mlaventure mentioned this pull request May 27, 2016
runcom added a commit to runcom/docker that referenced this pull request Jun 8, 2016
Upstream reference: moby#22918

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
crawford pushed a commit to crawford/docker that referenced this pull request Jun 14, 2016
Upstream reference: moby#22918

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
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.

None yet

7 participants