benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 113 forks source link

retry connection in couchbeam_uuids #121

Closed benoitc closed 9 years ago

benoitc commented 9 years ago

When the couchbeam attempts to get a UUIDS using a closed socket it get the following error:

=ERROR REPORT==== 9-Dec-2014::00:29:35 ===
** Generic server couchbeam_uuids terminating 
** Last message in was {get_uuids,
                           {server,<<"http://localhost:5984">>,
                               [{connect_timeout,200}]},
                           1}
** When Server state == {state}
** Reason for termination == 
** {{badmatch,{error,closed}},
    [{couchbeam_uuids,do_get_uuids,4,
                      [{file,"src/couchbeam_uuids.erl"},{line,90}]},
     {couchbeam_uuids,handle_call,3,
                      [{file,"src/couchbeam_uuids.erl"},{line,61}]},
     {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,580}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
** exception exit: {{{badmatch,{error,closed}},
                     [{couchbeam_uuids,do_get_uuids,4,
                                       [{file,"src/couchbeam_uuids.erl"},{line,90}]},
                      {couchbeam_uuids,handle_call,3,
                                       [{file,"src/couchbeam_uuids.erl"},{line,61}]},
                      {gen_server,handle_msg,5,
                                  [{file,"gen_server.erl"},{line,580}]},
                      {proc_lib,init_p_do_apply,3,
                                [{file,"proc_lib.erl"},{line,237}]}]},
                    {gen_server,call,
                                [couchbeam_uuids,
                                 {get_uuids,{server,<<"http://localhost:5984">>,
                                                    [{connect_timeout,200}]},
                                            1}]}}
     in function  gen_server:call/2 (gen_server.erl, line 182)
     in call from couchbeam:save_doc/4 (src/couchbeam.erl, line 563)
     ....
benoitc commented 9 years ago

There is no real reason to connect to couchdb to retrieve UUIDS. instead we should use our own proper module locally so we also remove one extra call.

kxepal commented 9 years ago

Here you the case when it could make a sense: uuids with utc_id algorithm when uuid isn't just an uuid, but just some magic id value. This magic is defined by utc_id_suffix which is server specific and you probably won't embed such into your code. But in overall yes, there are almost no reasons to call /__uuids from client side.

benoitc commented 9 years ago

@kxepal right... Also let's just fix the issue right now, if not it would need a major release.