Messages getting lost in erlang -


i having issues messages in erlang lost.

the code using works 100% correct when use manually, when code used in 'load test' test code in parallel lot of requests, messages never received @ receiver part. when logging steps , values of parameters, found out address send message to, correct one. message has no problems.

my question following: there knowledge of 'losing of messages' in erlang yet, bug in erlang itself?

i post code using if needed, don't think add lot of value question in particular.

update: main parts of application. quite lot of code illustrate problem, can not reproduce problem in simplified version. application allocation system, i.e. reserve collections of cells in grid in parallel. important parts are: globalmanager, actor control entire allocation system. rowmanager manage 1 row of entire grid , lock row when reservation made. when region of cells has reserved, function request_specific_cells called. function send reservation request rowmanagers of whom row has modified. when row manager has reserved region in row send confirmation globalmanager. when rowmanagers have send confirmation, confirmation send process initiated request, when 1 of managers failed, globalmanager send failure.

    globalmanager(grid) ->     receive         {pid, request_specific_cells, reservationid, coordinates, ctr, xx} ->             newgrid = request_specific_cells(grid, pid, reservationid, coordinates, ctr, xx);          {pid, confirm_region, resid, rid, sid, region, section, ctr, xx} ->             newgrid = confirm_region(grid, pid, resid, rid, sid, region, section, ctr, xx);          {pid, failed_region, rid, region, ctr, xx} ->             newgrid = failed_region(grid, pid, rid, region, ctr, xx);          else ->             erlang:display({unexpectedmessage, actor, else}),             newgrid = grid     end,     globalmanager(newgrid).   request_specific_cells(grid, pid, reservationid, coordinates, ctr, xx) ->     {{width, height}, gridrows, maxallocationsize, freecells, {unspecificrequests, nextid}, pendingrequests, blockedrows} = grid,     {x, y, w, h} = coordinates,     rows         = lists:seq(y,y+h-1),     % 1 of blocks have reserved blocked?     blockedrow   = lists:foldl(fun(b, acc) -> acc xor search_list(b,blockedrows) end, false, rows),     request      = lists:keyfind(reservationid, 1, unspecificrequests),     {reservationid, _} = request,     % need addresses of sections in regions has reserved.     subsectionids = [ spid || {_,spid} <- [ lists:keyfind(row, 1, gridrows) || row <- rows]],     % storing request enables rollback if 1 of registrations fails.     newpendingrequests = pendingrequests ++ [{length(pendingrequests), 0, lists:map(fun(s) -> {s,null} end, subsectionids)}],     % send registration command needed section each corresponding section manager.     [spid ! {self(), request, pid, reservationid, length(pendingrequests), coordinates, ctr, xx} || spid<- subsectionids],     newblockedrows = rows ++ blockedrows,     {{width, height}, gridrows, maxallocationsize, freecells, {unspecificrequests, nextid}, newpendingrequests, newblockedrows}     end.   confirm_region(grid, pid, urid, rid, sid, region, section, cttr, xx) ->     {dimensions, gridrows, maxallocationsize, freecells, {unspecificrequests, nextid}, pendingrequests, blockedrows} = grid,     {_,ry,_,_} = region,     if         % blocks have confirmed reservation entire request successful         (ctr+1) == length(spids) ->                  newunspecificrequests = lists:keydelete(urid, 1, unspecificrequests),                 newpendingrequests = lists:keydelete(rid, 1, pendingrequests),                 newspids = lists:keyreplace(sid, 1, spids, {sid, section}),                 [spid ! {self(), confirm_region, sec} || {spid, sec} <- newspids],                 pid ! {self(), request_specific_cells, rid, success};         true ->                  newunspecificrequests = unspecificrequests,                 % safe region has marked/rolled in row                 newspids = lists:keyreplace(sid, 1, spids, {sid, section}),                 % increase counter of confirmations                 newpendingrequests = lists:keyreplace(rid, 1, pendingrequests, {rid, ctr+1, newspids})     end,     newblockedrows = delete_list(ry, blockedrows)     {dimensions, gridrows, maxallocationsize, freecells, {newunspecificrequests, nextid}, newpendingrequests, newblockedrows}.    rowmanager(row) ->     receive         {mid, request, pid, urid, rid, region, ctr, xx} ->             newrow = request_region(row, mid, pid, urid, rid, region, ctr, xx);         else ->             erlang:display({unexpectedmessage, rowmanager, else}),             newrow = row     end,      rowmanager(newrow).  request_region(row, mid, pid, urid, rid, coordinates, ctr, xx) ->     {ry, content, modified} = row,     {x,_,w,_}    = coordinates,     if         modified == false ->                  free = region_is_empty({x,1,w,1}, content),                 if                     free -> newmodified = true,                             newcontent = mark_region({x,1,w,1}, content, reserved),                             mid ! {pid, confirm_region, urid, rid, self(), coordinates, {x,1,w,1}, ctr, xx};                     true -> newmodified = false,                             newcontent = content,                             mid ! {pid, failed_region, rid, coordinates, ctr, xx}                 end;         true -> newmodified = false,                 newcontent = content,                 mid ! {pid, failed_region, rid, coordinates, ctr, xx}     end,     {ry, newcontent, newmodified}.  

this code used reserver:

request_specific_cells(followuppid, reservationid, {x, y, width, height}, ctr, xx) ->    followuppid ! {self(), request_specific_cells, reservationid, {x, y, width, height}, ctr, xx},    receive       {followuppid, request_specific_cells, reservationid, successorfailure} ->         successorfailure end. 

i think receiver dies before answer received because know that

pid ! {self(), request_specific_cells, rid, success} 

from confirm/9 function executed correct values, not received @ function.

erlang has strong message delivery guarantees inside same node if receiver alive.

it seems have race condition in code. try write smaller example of application has same problem , post here.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -