Skip to content

Do not re-lock in SimpleGraph.Adj - #237

Open
AshSgDe29071999 wants to merge 1 commit into
Workiva:masterfrom
AshSgDe29071999:fix/simplegraph-adj-deadlock
Open

Do not re-lock in SimpleGraph.Adj#237
AshSgDe29071999 wants to merge 1 commit into
Workiva:masterfrom
AshSgDe29071999:fix/simplegraph-adj-deadlock

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

Adj already holds RLock and then called Degree, which takes RLock again. Go's RWMutex is not reentrant: a concurrent AddEdge writer waiting for the lock made that re-acquire hang forever.

Compute the adjacency list under the existing lock.

Fixes #232

Test

go test ./graph -run TestAdjDoesNotDeadlockWithAddEdge -count=1

Adj already holds RLock and then called Degree, which takes RLock
again. A concurrent AddEdge writer waiting for the lock made that
re-acquire hang forever.

See Workiva#232
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.

SimpleGraph - deadlock

1 participant