Discussion: should HTTP/2 pool skip over not ready connections?
Goose97 opened this issue · comments
We sometimes encounter this error in our production release:
{:error, %Finch.Error{reason: :read_only}}
This error indicates that the checked out pool is close for writing and only able to read responses. If the pool is in :disconnected
or :connected_read_only
state, it's not able to make requests (I'll refer these two states as not_ready
from now on). This problem is worsen if the reconnect process takes longer, eg: when network connections are unstable.
My point is we should be able to filter out not_ready
pools while performing lookup. Right now, there's no way to efficiently get pool's current state other than sending a message to it (GenServer.call, :sys.get_state, ...). How about lifting the pool state to an ets table?
I agree, when we lookup a pool/connection (for http2 they are the same thing), we should not return connections that are not ready for use. Maybe the connection should unregister itself from the Registry whenever it is not ready to accept new requests, and re-registry itself once it is ready again?
cool, this should work. I'll try a PR soon.
Sorry, I almost forgot about this. I've been kinda busy lately.