Существует сервер Centos 7 с Asterisk PBX 11.25.3 и mysql Ver 15.1 Distrib 10.3.18-MariaDB, для Linux (x86_64).
extensions.conf:
[from-main-asterisk]
exten => _9XXXXXXXXXXXX,1,MYSQL(Connect connid localhost root rootpasswd mydatabase)
exten => _9XXXXXXXXXXXX,n,GotoIf($["${connid}" = ""]?error,1)
exten => _9XXXXXXXXXXXX,n(select_sim),MYSQL(Query RESULTID ${connid} set autocommit=0)
exten => _9XXXXXXXXXXXX,n,MYSQL(Query RESULTID ${connid} START TRANSACTION)
exten => _9XXXXXXXXXXXX,n,MYSQL(Query RESULTID ${connid} SELECT sim_name FROM sim_stat where status = 'FREE' order by rand() limit 1 )
exten => _9XXXXXXXXXXXX,n(sqlresult),MYSQL(Fetch fetchid ${RESULTID} SIM_NAME)
exten => _9XXXXXXXXXXXX,n,MYSQL(Clear ${RESULTID})
exten => _9XXXXXXXXXXXX,n,MYSQL(Query RESULTID ${connid} UPDATE sim_stat set status = "BUSY" where sim_name = "${SIM_NAME}")
exten => _9XXXXXXXXXXXX,n,MYSQL(Query RESULTID ${connid} COMMIT)
exten => _9XXXXXXXXXXXX,n,Dial(SIP/gsm-${SIM_NAME}#${EXTEN:1},,g)
exten => _9XXXXXXXXXXXX,n,Hangup
exten => h,1,MYSQL(Query RESULTID ${connid} UPDATE sim_stat set status = "FREE" where sim_name = "${SIM_NAME}")
exten => h,n,MYSQL(Query RESULTID ${connid} COMMIT)
exten => h,n,MYSQL(Disconnect ${connid})
exten => error,1,NoOp(Database connection error!)
exten => error,n,Hangup
sip.conf:
[from-main-asterisk]
type=friend
host=x.x.x.x
qualify=yes
qualifyfreq=60
canreinvite=no
disallow=all
allow=alaw
context=from-main-asterisk
При одновременном поступлении более 15-20 вызовов из транкая получил сообщение:
WARNING[2239][C-00000389] app_mysql.c: aMYSQL_query: mysql_query failed. Error: Lock wait timeout exceeded; try restarting transaction
Есть ли ограничения для одновременных транзакций в MariaDB?