Deadlocks
When adding locks and unlocking code to a concurrent application, at some point you may see that your application has completely stopped, but not crashed. After much time spent digging through the code, adding extra print statements, and stepping through a debugger, you finally see it; a lock was not released! This situation is what is known as a deadlock.
The Go standard library does not have any tools to help detect and overcome deadlocks. However, there is support in the open source community. One such package being go-deadlock by GitHub user sacha-s. The go-deadlock package provides a drop-in replacement for the sync.Mutex and the sync.RWMutex, that monitors how long a lock on an object has been held. By default, when it detects ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access