Schedule HTTP/2 re-enable on NetVConnection owner thread#13362
Schedule HTTP/2 re-enable on NetVConnection owner thread#13362saimayithri wants to merge 1 commit into
Conversation
Refs: apache#13358 Signed-off-by: saimayithri <saimayithri@gmail.com>
JosiahWI
left a comment
There was a problem hiding this comment.
The code looks good! Thank you for this fix!
|
I'm adding this to the v10.2.x project in anticipation that it should be backported. |
|
[approve ci] |
|
The AuTest subcookie spuriously failed, and the HostDBProcessor regression test failed (unsure if this is spurious). |
|
Thanks for the review, assignment, and for running CI !! |
There was a problem hiding this comment.
The feedback from @wuxcer (#13358 (comment)) reveals that the NetVConnection thread isn't always the NetHandler thread. Could we schedule on nh->thread instead of netvc->thread?
|
Hi! I spent some time tracing this further, and I think I may have been focusing on the wrong comparison. From the current source, I couldn't find a path where netvc->thread and nh->thread diverge. They appear to be assigned together during initialization, and I couldn't find any later reassignment. However, @wuxcer's latest crash report seems to indicate something different: the mitigation check if (this->thread != this_ethread()) had already passed before MUTEX_TRY_LOCK(nh->mutex) failed. That made me wonder if the important distinction is actually between vc->thread and the thread currently holding nh->mutex, rather than vc->thread and nh->thread. When you mentioned that the NetVConnection thread isn't always the NetHandler thread, I just wanted to make sure I'm interpreting that correctly. Were you referring to nh->thread, or to the thread currently holding nh->mutex? I feel like I'm missing an important piece of the locking model, and I'd like to understand that before updating the scheduling target. |
|
Thank you for correcting my confusion, @saimayithri. As long as the netvc thread and the nh thread are the same, it is OK to schedule the queue change on the netvc thread. The only concern, then, is that that same thread must be holding the nh mutex when it calls the NetHandler method to add to the queue, or the |
|
Thanks! I don't think I've completely proven that yet. From what I've traced so far, my change ensures the reenable event is scheduled onto the NetVConnection/NetHandler owner thread, but I haven't yet verified whether that also guarantees I'll trace that path next and verify whether scheduling onto the owner thread is sufficient to satisfy the |
Refs: #13358
Summary
Http2CommonSession::state_complete_frame_read()schedulesHTTP2_SESSION_EVENT_REENABLEon the thread currently holding the sessionmutex.
That thread can differ from the underlying
NetVConnectionowner thread.When the re-enable handler later processes frames or releases streams, it can
reach
UnixNetVConnectionqueue operations from the wrong thread and triggerthe NetHandler lock assertion described in #13358.
This change schedules the re-enable event on the session
NetVConnection'sowner thread instead.
Changes
At both HTTP/2 re-enable scheduling sites:
VIOunchanged.get_netvc()->threadas the scheduling target instead ofget_mutex()->thread_holding.NetVConnectionbeforescheduling.
Validation
Built successfully with:
cmake --build build-dev -j4
Ran:
ctest --test-dir build-dev -j4
Scope
This PR addresses the HTTP/2 re-enable path from #13358 only. The separate
HTTP/1.1 cache-write teardown path remains under investigation.