Commit 1aad565
Roel Rymenants
Reverse lock order to avoid deadlock
In class AutorecoveringConnection:
maybeDeleteRecordedAutoDeleteExchange takes the locks on
- recordedExchanges
- consumers
maybeDeleteRecordedAutoDeleteQueue takes the locks on
- recordedQueues
- consumers
Since the latter one also calls the former, the following deadlock may occur
Thread1:
maybeDeleteRecordedAutoDeleteExchange
- locked recordedExchanges
- waiting for consumers (locked by thread2)
Thread2:
maybeDeleteRecordedAutoDeleteQueue
- locked recordedQueues
- locked consumers
maybeDeleteRecordedAutoDeleteExchange
- waiting for recordedExchanges (locked by thread1)
By reversing the locks, both flows will first lock consumers, avoiding taking other locks
in a different order1 parent 9863c16 commit 1aad565
File tree
1 file changed
+4
-4
lines changed- src/main/java/com/rabbitmq/client/impl/recovery
1 file changed
+4
-4
lines changedLines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
775 | | - | |
776 | | - | |
| 775 | + | |
| 776 | + | |
777 | 777 | | |
778 | 778 | | |
779 | 779 | | |
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | | - | |
791 | | - | |
| 790 | + | |
| 791 | + | |
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| |||
0 commit comments