[core] fix a recursive mutex locking in task#677
[core] fix a recursive mutex locking in task#677justonedev1 merged 2 commits intoAliceO2Group:masterfrom
Conversation
Fixes a bug reported in OCTRL-999.
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a recursive mutex locking issue in the Task implementation by bypassing the traditional lock in the GetTraits method.
- Introduces a lock-free version of GetTraits named getTraits
- Updates the SendEvent method to use the new lock-free version
Comments suppressed due to low confidence (2)
core/task/task.go:258
- Please confirm that the parent's GetTaskTraits method is implemented as a lock-free or safe alternative, as calling it here may not resolve the recursive mutex locking issue if it internally acquires a lock.
return t.parent.GetTaskTraits()
core/task/task.go:255
- [nitpick] Consider renaming 'getTraits' to more clearly indicate it is a lock-free variant (e.g., 'getTraitsLockFree') to avoid potential confusion with the original GetTraits.
func (t *Task) getTraits() Traits {
| } | ||
| return Traits{} | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't like how it is literally the same code for GetTraits() and getTraits() except t.parent part. I'd probably make getTraits(*parentRole) and call it from GetTraits, because the t.GetParent() usage in this case is not thread safe either way. We call it twice, so if there is a change of a parent from other goroutine, we might get different results on both calls due to race condition. With this change we will at least alway address the same parent, even if it changes half during the GetTraits call.
There was a problem hiding this comment.
did you mean something like this?
Fixes a bug reported in OCTRL-999.
The recursive locking happens in the following trace: