Skip to content

Commit

Permalink
Remove a few code spots with potential to deadlock
Browse files Browse the repository at this point in the history
to quickly summarize, our logging library (seelog) has the potential to
deadlock if a task update happens at the same time as it is trying to
unmarshal the task object into a string.

long-term we are working to replace this library, but for now we can
remove the potential to trigger this deadlock by removing the lock on
Task.String(), and remove an unecessary Debug log statement in the
AddStateChangeEvent function.

- remove lock from Task.String
- AddStateChangeEvent: remove log.Debugf statement
  • Loading branch information
sparrc committed Feb 18, 2021
1 parent a7f7235 commit d47ad92
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 3 deletions.
2 changes: 0 additions & 2 deletions agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2247,8 +2247,6 @@ func (task *Task) GetExecutionStoppedAt() time.Time {

// String returns a human readable string representation of this object
func (task *Task) String() string {
task.lock.Lock()
defer task.lock.Unlock()
return task.stringUnsafe()
}

Expand Down
1 change: 0 additions & 1 deletion agent/eventhandler/task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func NewTaskHandler(ctx context.Context,
func (handler *TaskHandler) AddStateChangeEvent(change statechange.Event, client api.ECSClient) error {
handler.lock.Lock()
defer handler.lock.Unlock()
seelog.Debugf("handling Event: %v", change)
switch change.GetEventType() {
case statechange.TaskEvent:
event, ok := change.(api.TaskStateChange)
Expand Down

0 comments on commit d47ad92

Please sign in to comment.