[Freeswitch-users] Does nibble execute sql queries in single transaction ?
Steven Ayre
steveayre at gmail.com
Tue Sep 6 23:22:36 MSD 2016
bill_event() charges atomically:
sql = dsql = switch_mprintf("UPDATE %s SET %s=%s-%f WHERE %s='%s'",
globals.db_table, globals.db_column_cash, globals.db_column_cash,
billamount, globals.db_column_account, billaccount);
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.
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.
On 6 September 2016 at 05:50, Mohd Kamal Mustafa <kamal at xoxzo.com> wrote:
> If not, is there a possibilities of reach condition where updates from
> multiple channels override each other. For example, 2 incoming calls
> at the same time to 2 different numbers, but owned by single user -
> that mean nibble will be updating the same record in database.
>
> I'm planning to add "FOR UPDATE" clause to the custom_sql_lookup:-
>
> SELECT cash AS nibble_balance FROM accounts WHERE
> account_code='${nibble_account} FOR UPDATE
>
> But if each query run inside their own transaction, that would be no use.
>
> Thank you.
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160906/08a791eb/attachment-0001.html
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list