[erlang-questions] Looking for advice on simultaneous data modification

Daniil Churikov ddosia@REDACTED
Thu Jun 18 11:28:41 CEST 2015


Hi Sergej. That was my intention, but I was looking for more mature
solution. Maybe with some efforts
`global:trans` (suggested by Robert Raschke) could be adopted.

2015-06-17 15:00 GMT+01:00 Sergej Jurecko <sergej.jurecko@REDACTED>:

> Spawn a process to execute delete, use register/2 as a kind of mutex,
> anyone waiting for delete to finish should attach to it with monitor/2.
>
> case catch register(lock,self()) of
> true ->
>  Havelock;
> {‘EXIT’,_} ->
>  erlang:monitor(process,lock),
>  ….wait for finish
> end,
>
> Or use a proper database… Can you share with us why you’re not using one?
>
>
> Sergej
>
> From: <erlang-questions-bounces@REDACTED> on behalf of Daniil Churikov
> Date: Wednesday 17 June 2015 15:53
> To: <erlang-questions@REDACTED>
> Subject: [erlang-questions] Looking for advice on simultaneous data
> modification
>
> Hello dear list. I am looking for advice to, perhaps, very common problem.
>
> I have database which does not support transactions, only CAS operations
> for single record.
> I have one-to-many relationship between 2 tables, and I need to implement
> cascade deletion of dependent records from table_2 when main record from
> table_1 was deleted. All the operations may happen in different processes
> simultaneously.
> So my intention is to do some kind of a mutex, which incorporate following
> properties:
> * when main record is in deletion-state, every other action on main and/or
> dependent record should wait until it will be deleted;
> * if main record is in normal-state, all dependencies may be modified
> without any strict order.
>
> Is there any library in the wild which allow me to do this kind of mutex?
> Maybe I have chosen wrong approach? Any suggestions?
>
> Thanks!
> _______________________________________________ erlang-questions mailing
> list erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150618/18c55aff/attachment.htm>


More information about the erlang-questions mailing list