<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div><div>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. </div><div><br></div><div>case catch register(lock,self()) of</div><div>true -></div><div> Havelock;</div><div>{‘EXIT’,_} -></div><div> erlang:monitor(process,lock),</div><div> ….wait for finish</div><div>end,</div><div><div id="MAC_OUTLOOK_SIGNATURE"></div></div></div><div><br></div><div>Or use a proper database… Can you share with us why you’re not using one?</div><div><br></div><div><br></div><div>Sergej</div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> <<a href="mailto:erlang-questions-bounces@erlang.org">erlang-questions-bounces@erlang.org</a>> on behalf of Daniil Churikov<br><span style="font-weight:bold">Date: </span> Wednesday 17 June 2015 15:53<br><span style="font-weight:bold">To: </span> <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br><span style="font-weight:bold">Subject: </span> [erlang-questions] Looking for advice on simultaneous data modification<br></div><div><br></div><div dir="ltr"><div>Hello dear list. I am looking for advice to, perhaps, very common problem.<br><br>I have database which does not support transactions, only CAS operations for single record.<br>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.<br>So my intention is to do some kind of a mutex, which incorporate following properties:<br>* when main record is in deletion-state, every other action on main and/or dependent record should wait until it will be deleted;<br>* if main record is in normal-state, all dependencies may be modified without any strict order.<br><br>Is there any library in the wild which allow me to do this kind of mutex?<br>Maybe I have chosen wrong approach? Any suggestions?<br><br></div>Thanks!<br></div>
_______________________________________________
erlang-questions mailing list
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</span></body></html>