util/async: avoid blocking Append on Exec cancellation - #2034
Conversation
fix tikv#2033 Signed-off-by: zyguan <zhongyangguan@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesRunLoop cancellation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[LGTM Timeline notifier]Timeline:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fix #2033
RunLoop.Appendcould block indefinitely when racing with cancellation of a waitingRunLoop.Exec.Appendchanges the state fromStateWaitingtoStateIdleunder the mutex, then sends a notification through theunbuffered
readychannel after releasing the mutex. IfExecselectedctx.Done()and returned before receiving thatnotification, the
Appendcaller was left blocked. When invoked from an async batch response callback, this could stopthe batch receive loop from retiring the request and processing later responses on the same stream.
Changes:
Appendhasalready committed to sending a notification.
Exec, ensuring the notifyingAppendcan complete.Execsafety invariant.Execbehavior.Exectest deterministic by synchronizing on the first executor enteringStateRunning.Summary by CodeRabbit
Bug Fixes
Tests