benoitc / couchbeam

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

getting multiple uuids crashes uuid caching server #70

Closed kuloshius closed 12 years ago

kuloshius commented 12 years ago

couchbeam:get_uuid(Server) returns uuid as expected. As I understand internally it fetches 1000 uuids at once and caches them in ets table. If you request one uuid at the time when there is no uuids left in ets the server behaves as expected - fetches another 1000 uuids from couchDB server.

couchbeam:get_uuids(Server, Count) returns the Count of uuids as expected when Count is less than number of uuids left in ets table, i.e if there is 10 uuids left and you call couchbeam:get_uuids(Server, 11) gen_server crashes.

couchbeam:get_uuids(couchbeam:server_connection(), 999) -> ListOfUuids %% 1 uuid left in ets. couchbeam:get_uuids(couchbeam:server_connection(), 2) -> =ERROR REPORT==== 21-Mar-2012::14:44:41 === * Generic server couchbeam_uuids terminating * Last message in was {get_uuids,{server,"127.0.0.1",5984,[],[]},2} * When Server state == {state} * Reason for termination == * {function_clause,[{couchbeam_uuids,do_get_uuids1, [[<<"16d84db3e3c1dd9f04fc7b8be69d7223">>], [],1], [{file,"src/couchbeam_uuids.erl"}, {line,90}]}, {couchbeam_uuids,do_get_uuids,4, [{file,"src/couchbeam_uuids.erl"}, {line,80}]}, {couchbeam_uuids,handle_call,3, [{file,"src/couchbeam_uuids.erl"}, {line,48}]}, {gen_server,handle_msg,5, [{file,"gen_server.erl"},{line,578}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}]} * exception exit: {{function_clause, [{couchbeam_uuids,do_get_uuids1, [[<<"16d84db3e3c1dd9f04fc7b8be69d7223">>],[],1], [{file,"src/couchbeam_uuids.erl"},{line,90}]}, {couchbeam_uuids,do_get_uuids,4, [{file,"src/couchbeam_uuids.erl"},{line,80}]}, {couchbeam_uuids,handle_call,3, [{file,"src/couchbeam_uuids.erl"},{line,48}]}, {gen_server,handle_msg,5, [{file,"gen_server.erl"},{line,578}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}]}, {gen_server,call, [couchbeam_uuids, {get_uuids,{server,"127.0.0.1",5984,[],[]},2}]}} in function gen_server:call/2 (gen_server.erl, line 180) (thinkpad@thinkpad)40> =CRASH REPORT==== 21-Mar-2012::14:44:41 === crasher: initial call: couchbeam_uuids:init/1 pid: <0.122.0> registered_name: couchbeam_uuids exception exit: {function_clause, [{couchbeam_uuids,do_get_uuids1, [[<<"16d84db3e3c1dd9f04fc7b8be69d7223">>],[],1], [{file,"src/couchbeam_uuids.erl"},{line,90}]}, {couchbeam_uuids,do_get_uuids,4, [{file,"src/couchbeam_uuids.erl"},{line,80}]}, {couchbeam_uuids,handle_call,3, [{file,"src/couchbeam_uuids.erl"},{line,48}]}, {gen_server,handle_msg,5, [{file,"gen_server.erl"},{line,578}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}]} in function gen_server:terminate/6 (gen_server.erl, line 737) ancestors: [couchbeam_sup,<0.69.0>] messages: [] links: [<0.70.0>] dictionary: [] trap_exit: true status: running heap_size: 17711 stack_size: 24 reductions: 4809 neighbours:

=SUPERVISOR REPORT==== 21-Mar-2012::14:44:41 === Supervisor: {local,couchbeam_sup} Context: child_terminated Reason: {function_clause, [{couchbeam_uuids,do_get_uuids1, [[<<"16d84db3e3c1dd9f04fc7b8be69d7223">>],[],1], [{file,"src/couchbeam_uuids.erl"},{line,90}]}, {couchbeam_uuids,do_get_uuids,4, [{file,"src/couchbeam_uuids.erl"},{line,80}]}, {couchbeam_uuids,handle_call,3, [{file,"src/couchbeam_uuids.erl"},{line,48}]}, {gen_server,handle_msg,5, [{file,"gen_server.erl"},{line,578}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,227}]}]} Offender: [{pid,<0.122.0>}, {name,couchbeam_uuids}, {mfargs,{couchbeam_uuids,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}]