cmullaparthi / ibrowse

Erlang HTTP client
Other
516 stars 190 forks source link

Get a new lb pid if existing pid is not alive #166

Closed jaydoane closed 3 years ago

jaydoane commented 5 years ago

It's possible for the connection process associated with a pid in the ibrowse_lb ets table to die, yet remain in the table, in which case subsequent requests to the corresponding {Host, Port} will result in an error like the following:

(node1@127.0.0.1)9> ibrowse:send_req("http://localhost:15984", [], get).
                ** exception exit: {noproc,
                       {gen_server,call,
                           [<0.2451.0>,
                            {spawn_connection,
                                {url,"http://localhost:15984","localhost",15984,
                                    undefined,undefined,"/",http,hostname},
                                10,10,
                                {[],false},
                                []}]}}
     in function  gen_server:call/2 (gen_server.erl, line 215)
     in call from ibrowse:try_routing_request/14 (src/ibrowse.erl, line 377)

This checks whether the pid about to be returned from the table is alive, and if not, the entry is deleted, and a new pid is obtained.

jaydoane commented 3 years ago

@cmullaparthi do you have any interest including this commit in master?

FWIW, it's been included in recent CouchDB releases, and is also running in production at IBM/Cloudant for a couple years now, with no issues.

cmullaparthi commented 3 years ago

@jaydoane thanks for the nudge.