Commit e6b7b0b
authored
Fix for lock order inversion reported by TSAN. (#2634)
We have the following (summarized) reports from TSAN about
lock order inversion that are potential deadlock cases:
1)
First Thread:
stack:
PreProcessor::releaseClientPreProcessRequestSafe -> lock: lock_guard<mutex> lock(reqEntry->mutex)
RequestsBatch::releaseReqsAndSendBatchedReplyIfCompleted -> lock: const lock_guard<mutex> lock(batchMutex_)
Second Thread:
stack:
preprocessor::RequestsBatch::registerBatch -> const std::lock_guard<std::mutex> lock(batchMutex_)
PreProcessor::registerRequest
PreProcessor::registerAndHandleClientPreProcessReqOnNonPrimary
PreProcessor::handleSingleClientRequestMessage -> lock_guard<mutex> lock(reqEntry->mutex)
2)
First Thread:
stack:
RequestsBatch::registerBatch -> lock: const std::lock_guard<std::mutex> lock(batchMutex_)
PreProcessor::registerRequestOnPrimaryReplica
PreProcessor::handleSingleClientRequestMessage -> lock: lock_guard<mutex> lock(reqEntry->mutex);
Second Thread:
stack:
PreProcessor::releaseClientPreProcessRequestSafe -> lock: lock_guard<mutex> lock(reqEntry->mutex)
RequestsBatch::cancelRequestAndBatchIfCompleted -> lock: const lock_guard<mutex> lock(batchMutex_);
We resolve those situations by releasing the lock on batchMutex_ before the
invocations to releaseClientPreProcessRequestSafe in releaseReqsAndSendBatchedReplyIfCompleted
and cancelRequestAndBatchIfCompleted.1 parent 69e02ea commit e6b7b0b
1 file changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | | - | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| 224 | + | |
222 | 225 | | |
| 226 | + | |
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
| |||
0 commit comments