GeezerVison is showing github.com — DefaultHttp2RemoteFlowController: writeAllocatedBytes & Endless loop · Issue #11959 · netty/netty
DefaultHttp2RemoteFlowController: writeAllocatedBytes & Endless loop #11959DescriptionThere is a small probability I can't shut down a stream normally.
and I found I'm stuck in an endless loop at these code:
while (!cancelled && (frame = peek()) != null) {
int maxBytes = min(allocated, writableWindow());
if (maxBytes <= 0 && frame.size() > 0) {
// The frame still has data, but the amount of allocated bytes has been exhausted.
// Don't write needless empty frames.
break;
}
writeOccurred = true;
int initialFrameSize = frame.size();
try {
frame.write(ctx, max(0, maxBytes));
if (frame.size() == 0) {
// This frame has been fully written, remove this frame and notify it.
// Since we remove this frame first, we're guaranteed that its error
// method will not be called when we call cancel.
pendingWriteQueue.remove();
frame.writeComplete();
}
} finally {
// Decrement allocated by how much was actually written.
allocated -= initialFrameSize - frame.size();
}
}
my pendingWriteQueue had 2 frame, and the first one cannot always be removed, the second is endStream.
Netty version
4.1.63.Final Activitynormanmaurer commented on Dec 28, 2021 @lin233 can you provide some more details about what maxBytes is and frame.size() ? lin233 commented on Dec 28, 2021 maxBytes = 19, frame.size() = 19 ,allocated = 19


other details:
 lin233 commented on Dec 28, 2021 @normanmaurer Is there anything else i can provide? Thank you for your attention. RK23HUNTER commented on Dec 29, 2021 whirt one progarm and print chrisvest commented on Jan 5, 2022 Is the frame.size() not changed by the write() call for some reason? lin233 commented on Jan 6, 2022
yes, the frame.size() not changed. normanmaurer commented on Jan 6, 2022 @lin233 is there a way for us to reproduce easily ? lin233 commented on Jan 7, 2022 The time It happened was always when I disconnect grpc connections, and the stream state is "HALF_CLOSED_REMOTE". Maybe connect and disconnect frequent grpc with high concurrency can reproduce easily. and my situation is two-way flow. lin233 commented on Jan 7, 2022 The problem will put the service into suspended animation. If it is difficult to find out why the frame.size() cannot be changed, can we make it not stuck in an infinite loop when frame.size() cannot be changed for some reason?
Thank you for your attention. normanmaurer commented on Jan 7, 2022 @lin233 btw 4.1.63.Final is really old. Can you upgrade to latest netty version and see if this still happens ? lin233 commented on Jan 10, 2022 normanmaurer commented on Jan 11, 2022 lin233 commented on Jan 11, 2022 normanmaurer commented on Jan 11, 2022 @lin233 can you provide me a program that I can run here and reproduce ? normanmaurer commented on Aug 10, 2024 @koo-taejin thanks a lot for all the details... it really helped me to understand what is wrong here. Fix should be this #14220 koo-taejin commented on Aug 12, 2024 @normanmaurer
I have a question.
I thought the code I mentioned would not throw an exception and would continue to loop infinitely.
// io.netty.channel.AbstractCoalescingBufferQueue#remove
if (bufAndListenerPairs.isEmpty()) {
assert readableBytes == 0;
return removeEmptyValue();
}
However, the fix seems to fix the problem in the case where an exception is thrown.
I may have misunderstood because I do not have enough knowledge about netty.
Thank you for your quick response to this issue. normanmaurer commented on Aug 13, 2024 @koo-taejin I think what happened is that it did throw an IllegalReferenceCountException at some point and so things did end up in an inconsistent state which never could break recovered. This is not possible anymore with this change koo-taejin commented on Aug 13, 2024
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|