Commit d2d56a6
committed
[consensus] fix deadlock during recovery (#24292)
## Description
#24024 introduced a potential
deadlock when recovering consensus. Possible sequence of events:
1. Thread A: acquires `dag_state` read lock for the duration of the
function call in
`recover_blocks_after_round(observer.dag_state.read().gc_round())`
2. Thread B: `CommitFinalizer::run()` tries to acquire the `dag_state`
write lock, and is blocked on the reader lock from (1)
3. Thread A: `recover_and_vote_on_blocks()` tries to acquire read lock
on `dag_state` again. This usually succeeds but in this case because of
(2), this is blocked, causing a deadlock.
Also:
- Run the last step of `TransactionCertifier` recovery in a blocking
thread.
- Improve logging.
## Test plan
CI
The affected validator is fixed.1 parent 78afac0 commit d2d56a6
File tree
4 files changed
+28
-9
lines changed- consensus/core/src
- crates/sui-core/src
4 files changed
+28
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
83 | 90 | | |
84 | 91 | | |
85 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | | - | |
123 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
124 | 134 | | |
125 | 135 | | |
126 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1441 | 1441 | | |
1442 | 1442 | | |
1443 | 1443 | | |
1444 | | - | |
| 1444 | + | |
1445 | 1445 | | |
1446 | 1446 | | |
1447 | 1447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
0 commit comments