<div dir="ltr">bill_event() charges atomically:<br><br>sql = dsql = switch_mprintf("UPDATE %s SET %s=%s-%f WHERE %s='%s'", globals.db_table, globals.db_column_cash, <wbr>globals.db_column_cash, billamount, globals.db_column_account, billaccount);<div><br></div><div>That UPDATE query won't conflict with any other queries running at the same time, they'll lock on each other so one updates the row at a time.<br><div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">The balance fetched by get_balance isn't used to update the balance so it shouldn't matter if there are multiple calls. Both will use UPDATE and overlapping calls will update the balance correctly. They'll then both spot if the balance drops below the minimum.                </span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 September 2016 at 05:50, Mohd Kamal Mustafa <span dir="ltr"><<a href="mailto:kamal@xoxzo.com" target="_blank">kamal@xoxzo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If not, is there a possibilities of reach condition where updates from<br>
multiple channels override each other. For example, 2 incoming calls<br>
at the same time to 2 different numbers, but owned by single user -<br>
that mean nibble will be updating the same record in database.<br>
<br>
I'm planning to add "FOR UPDATE" clause to the custom_sql_lookup:-<br>
<br>
SELECT cash AS nibble_balance FROM accounts WHERE<br>
account_code='${nibble_account<wbr>} FOR UPDATE<br>
<br>
But if each query run inside their own transaction, that would be no use.<br>
<br>
Thank you.<br>
<br>
______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions<wbr>.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.o<wbr>rg</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswi<wbr>tch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/ma<wbr>ilman/listinfo/freeswitch-user<wbr>s</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.frees<wbr>witch.org/mailman/options/<wbr>freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br></div></div></div>