stream: fix flaky stream destroy, reachable from HTTP/2 teardown - #65079
stream: fix flaky stream destroy, reachable from HTTP/2 teardown#65079pimterry wants to merge 2 commits into
Conversation
Signed-off-by: Tim Perry <pimterry@gmail.com>
|
cc @nodejs/http2 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65079 +/- ##
==========================================
+ Coverage 90.29% 90.32% +0.03%
==========================================
Files 759 759
Lines 247598 248458 +860
Branches 46680 46869 +189
==========================================
+ Hits 223566 224420 +854
+ Misses 15503 15448 -55
- Partials 8529 8590 +61
🚀 New features to boost your workflow:
|
Stress testing inconclusive - the tests passed on both main and this branch, even with multiple runs. They're definitely failing in PRs though. I can reliably reproduce the reported failure locally (that first failure above, it hits for 2-3% of runs) and validate that it's fixed with this change. The trace is where is crashes on my machine with the matching error, and it's clearly a broken flow, so I think this is the right fix regardless. |
mcollina
left a comment
There was a problem hiding this comment.
lgtm
I concur with the analysis
|
Even with this PR's change I can still fail test-stream-pipeline-http2.js with a timeout 31/1000 times. Without it about 56/1000 times. This diff that claude spit out to deflake test-stream-pipeline-http2.js makes that 0/1000 with or without this PR, but I don't know enough about this subsystem to say whether that retains the point of the test or not. |
Yes, sorry if the description isn't clear - both failing tests are related to that PR, but this PR only fixes the first of the two. I.e. I haven't opened a fix for the second yet, because I think it's actually exposed a real bug that's a bit complicated, and mac-only. Looks like that fix would resolve the test, but from what I can tell so far there's a real underlying deadlock that's reproducible independently, so I want to get a proper fix for that instead. I'll update when I have more info there. |
|
@pimterry can you land this with the fix/workaround i posted to the remaining flake knowing you'll revisit the underlying deadlock problem and possibly change it again? |
This does not solve the remaining underlying deadlock issue, but does bound the test behaviour in a way that seems to avoid failures in practice. Deadlock fix to come separately later. Co-authored-by: Filip Skokan <panva.ip@gmail.com> Signed-off-by: Tim Perry <pimterry@gmail.com>
|
Good plan @panva, now done 👍. I'll open the other fix separately. I've got it working now but the deadlock comes from code we added to resolve past CVEs, so needs some thought and it'd be nice not to rush it. |
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Tim Perry <pimterry@gmail.com> PR-URL: #65079 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This does not solve the remaining underlying deadlock issue, but does bound the test behaviour in a way that seems to avoid failures in practice. Deadlock fix to come separately later. Co-authored-by: Filip Skokan <panva.ip@gmail.com> Signed-off-by: Tim Perry <pimterry@gmail.com> PR-URL: #65079 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
|
Landed in 780229b...404b0cf |
Some of the HTTP/2 tests have become flaky, e.g. nodejs/reliability#1623 shows yesterday:
Best guess is these are both due to the window update PR #64623 (cc @mcollina) since the timing lines up exactly. I think this is really just the window size highlighting existing issues though.
This PR fixes the first issue, which triggers flakes in parallel/test-worker-terminate-http2-respond-with-file. I'll kick off a stress test to confirm, but I can reproduce this locally, and reproduced as resolved with this fix. I'm still working on the 2nd, which only reproduces on Mac and seems a bit more complex.
Actual failure in the 1st test is a crash with
pure virtual method called. That fires due toReadStopwithin this trace:I.e. during destroy within the destructor chain, we call OnStreamRead, which tries to call
stream()->ReadStopinside the sources destructor.This is only called because OnStreamDestroy manually calls OnStreamRead with an error code to reuse its error/eof teardown logic. We don't need most of that in the destruction scenario (which is only ever called from
~StreamResource, where the stream is already dead).I've refactored out the relevant bit to split them up (just guarding just fails in the next line, where
previous_listener_is also null). That then exposed two other bugs for the same state, where two other methods that get reached later in this teardown flow also fail to check if the stream is already destroyed - those just need simple guards.Seems like this is a flaky race because it depends on whether the sink (Http2Stream) or the file handle gets destroyed first by
Cleanup().