-
Notifications
You must be signed in to change notification settings - Fork 81
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(metadata): mutex for concurrency #176
base: main
Are you sure you want to change the base?
Conversation
d4786d2
to
fa7f73d
Compare
Signed-off-by: Justin Bera <[email protected]>
fa7f73d
to
773b104
Compare
type MD struct { | ||
data map[string][]string | ||
mu sync.RWMutex | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this suppose to be used like a http.Header
where you need to Clone
when sharing with other "requests", or suppose to be shared and need a mutex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both ways are fine and we just need to stick with one, I just think the change will be easier to operate with the mutex solution given that there are MD objects that are mutated with the Set
and Append
(and setRequest
) functions (like here)
This looks more like a mishandling of metadata and not something we should need locks for. |
I think if |
As @djdongjin suggested, I think there are 2 ways of dealing with this issue: we can either make the MD object non-mutable or use mutexes to make sure the projects that are consuming containerd/ttrpc cannot reach concurrent operation issues. Given that the current implementation already relies on updating the MD objects in place (example here and here), I think it would take less effort to implement the second solution (hence my proposal) but I'm not strongly opinionated on the matter. I would however not recommend only changing the |
Description
This PR brings a fix for containerd/containerd#11138
It consists in a tiny change of the
ttrpc.MD
object to make it safer by preventing the access of its content from outside this project and adding a RW mutex.Release plan
Here are the projects that are consuming ttrpc and need to be updated: