gen_server locked for some time
Mikael Karlsson
karlsson.rm@REDACTED
Sat Nov 30 06:42:44 CET 2019
Hi Roberto,
For the smaller data updates using the gen_server:cast, which returns
immediate, is an option if you do not need to check any reply values.
Increasing the timeout using gen_server:call/3 is another if your clients
accept to be blocked for the complete time during bulk update. In that case
you could consider using the gen_statem instead which has a default timeout
of infinity for the call function.
I guess the aboves are not possible? so when offloading bulk write to a
separate process you can maybe add some state handling in your gen_server
(gen_statem) so that you process the smaller updates into an internal queue
during the bulk write and postpone processing them until the write is
finished. The gen_statem has postpone functions (which will still block
your client) as well as insertion of internal events but I am not sure how
useful they are in your case.
Mikael
Den fre 29 nov. 2019 kl 23:47 skrev Roberto Ostinelli <ostinelli@REDACTED>:
> All,
> I have a gen_server that in periodic intervals becomes busy, eventually
> over 10 seconds, while writing bulk incoming data. This gen_server also
> receives smaller individual data updates.
>
> I could offload the bulk writing routine to separate processes but the
> smaller individual data updates would then be processed before the bulk
> processing is over, hence generating an incorrect scenario where smaller
> more recent data gets overwritten by the bulk processing.
>
> I'm trying to see how to solve the fact that all the gen_server calls
> during the bulk update would timeout.
>
> Any ideas of best practices?
>
> Thank you,
> r.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20191130/f28a2e8d/attachment.htm>
More information about the erlang-questions
mailing list