recycle RequestInfo when Request is reused in pool#868
Conversation
|
Are you trying to fix a problem you noticed, or is this PR based on code analysis ? |
|
Sorry. I don't understand what you mean. My issue is that the metrics in org.apache.coyote.RequestGroupInfo#removeRequestProcessor is not counted correctly when org.apache.coyote.http2.Http2Protocol#discardRequestsAndResponses is false(default). This PR can resolve this issue partially, because there is still some special scenarios that miss some count. I hope you can give an better solution. |
|
Definitely this PR is wrong. RequestInfo is not the stats for an individual request, so it should not be reset. |
|
HTTP/2 is handled differently because of the multiplexing. We probably do need a |
@rmaucher When the org.apache.coyote.Request pool is used, its org.apache.coyote.Request#reqProcessorMX is not recycled after the request is recycled. So when org.apache.coyote.RequestGroupInfo#removeRequestProcessor is run, its stat count is counted many times. So the result count in org.apache.coyote.RequestGroupInfo will be wrong. |
That looks correct, you know that code better than I do. |
@markt-asf For this solution, there is also a concurrency problem. Because the request has already returned to the pool on the line 150 of StreamProcessor. Then the recycle method is executed on line 151 of StreamProcessor. In the progress, the request has been returned to the pool may be borrowed by another request and its reqProcessorMX may has been changed. |
|
Fixed in 4dc1a0f and back-ported |


The request statistics will be wrong when Request object is reused in the object pool.