valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.94k stars 1.76k forks source link

TestHostClientMaxConnWaitTimeoutError test case sometimes fails #1832

Closed newacorn closed 3 months ago

newacorn commented 3 months ago

The current implementation makes some incorrect assumptions about observing changes in the state of wantConn.

The following two pull requests failed the GitHub workflow named test due to the TestHostClientMaxConnWaitTimeoutError test case. https://github.com/valyala/fasthttp/pull/1818 https://github.com/valyala/fasthttp/pull/1829

Of course, we don't need to guarantee that the return value of HostClient.connsWait.len() is zero when all client calls have exited, because this doesn't affect the correctness of the program in the same way as the HostClient.MaxConns field does.

There is a test in the suite, TestHostClientMaxConnWaitTimeoutError, which can cause the test to fail under certain conditions. We either need to remove this test or find a way to fix it. Additionally, false waiters could slightly impact the number of iterations in the loop during handle MaxConns semaphore in the HostClient.releaseConn method.

This fix should resolve the issue. The reason for the failure of this test case is related to the issue described in https://github.com/valyala/fasthttp/issues/1830.

erikdubbelboer commented 3 months ago

Thanks!