You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NethVoice: CTI queue calls slow and database saturated on busy instances #8406
On a NethVoice instance with many calls per day, the Calls tab of the CTI Queues page takes 20 seconds or more to load and the whole instance slows down: the database is saturated and new call records (CDR) wait to be written.
Steps to reproduce
Use an instance with a busy day of calls (in the reported case about 20,000 call records in the last 24 hours, with queues).
Log in to the CTI as a queue agent and open Queues > Calls, leaving the page open.
On the database, look at the running queries: SHOW PROCESSLIST in asteriskcdrdb.
Expected behavior
The Calls tab loads in less than a second and does not slow down the rest of the system.
Actual behavior
The queue recall query (GET /astproxy/queue_recall/...) runs for about 19 seconds. Meanwhile the Asterisk insert into daily_cdr waits with Waiting for table level lock. The middleware gives up on the request (context deadline exceeded, ECONNRESET in the server log), and since the page asks again every 20 seconds without waiting for the previous answer, requests pile up.
EXPLAIN shows a full table scan of daily_cdr in the lookups by uniqueid, although that index exists. The index has no statistics (cardinality NULL, the table was never analyzed), so MariaDB 11.8 thinks the index is useless. The same NULL statistics are on every instance checked; only the busiest ones are slowed down.
Workaround
Refresh the statistics of the table, it does not change any data:
Afterwards EXPLAIN of the query shows ref on the uniqueid index and the query takes 0.18 seconds instead of 19. The statistics get old again with the daily cleanup of the table.
Setup: a NethVoice instance with queues and some call history; at least one CTI user who is a queue agent with the permission to see the queue calls. To see the effect of the fix the daily_cdr table needs many rows (thousands of calls in the last 24 hours), but every check below also works on a small instance. Database commands run in the module with:
Before the update, SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_NAME='daily_cdr' returns MyISAM; note SELECT COUNT(*) FROM daily_cdr
Update to the testing release: the same query returns InnoDB and the row count is the same (or higher, if calls were made meanwhile)
Make some calls: they are in daily_cdr, in the CTI history and, for queue calls, in Queues > Calls
Test Case 2 - New installation
On a new instance daily_cdr is created as InnoDB
Test Case 3 - Hourly cleanup
runagent -m nethvoice1 systemctl --user start nethvoice-cdr-cleanup: the journal shows asteriskcdrdb.daily_cdr analyze status OK and the rows older than 24 hours are gone
Test Case 4 - Queue calls page
CTI > Queues > Calls loads quickly and shows lost and answered calls as before, with filters (outcome, queues, text) and paging working
Queue Manager > Not managed shows the same lost calls as before
With the page open, the browser sends one queue_recall request per refresh interval, never a new one while the previous is still running
Test Case 5 - Slow database (optional)
In a second database session run LOCK TABLES queue_log WRITE; SELECT SLEEP(140); UNLOCK TABLES; and keep Queues > Calls open: SHOW PROCESSLIST never shows more than one recall query, after about 120 s it stops with max_statement_time exceeded in the nethcti-server log, and the page loads again once the lock is released
Activity
fix: slow queue calls on busy instances (#1374)
edospadoni commentedon Dec 2, 2026
Test
PRs: nethesis/ns8-nethvoice#1374
Setup: a NethVoice instance with queues and some call history; at least one CTI user who is a queue agent with the permission to see the queue calls. To see the effect of the fix the
daily_cdrtable needs many rows (thousands of calls in the last 24 hours), but every check below also works on a small instance. Database commands run in the module with:Test Case 1 - Update of an existing instance
SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_NAME='daily_cdr'returnsMyISAM; noteSELECT COUNT(*) FROM daily_cdrInnoDBand the row count is the same (or higher, if calls were made meanwhile)daily_cdr, in the CTI history and, for queue calls, in Queues > CallsTest Case 2 - New installation
daily_cdris created asInnoDBTest Case 3 - Hourly cleanup
runagent -m nethvoice1 systemctl --user start nethvoice-cdr-cleanup: the journal showsasteriskcdrdb.daily_cdr analyze status OKand the rows older than 24 hours are goneTest Case 4 - Queue calls page
queue_recallrequest per refresh interval, never a new one while the previous is still runningTest Case 5 - Slow database (optional)
LOCK TABLES queue_log WRITE; SELECT SLEEP(140); UNLOCK TABLES;and keep Queues > Calls open:SHOW PROCESSLISTnever shows more than one recall query, after about 120 s it stops withmax_statement_time exceededin the nethcti-server log, and the page loads again once the lock is releasedTesting release: 1.8.8-testing.18 (nethesis/ns8-nethvoice#1374)