Skip to content

NethVoice: CTI queue calls slow and database saturated on busy instances #8406

Todo

Description

@edospadoni

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

  1. 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).
  2. Log in to the CTI as a queue agent and open Queues > Calls, leaving the page open.
  3. 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:

runagent -m nethvoice1 podman exec -i mariadb sh -c 'mariadb -uroot -p"$MARIADB_ROOT_PASSWORD" asteriskcdrdb -e "ANALYZE TABLE daily_cdr"'

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.

Components

  • NethVoice 1.8.7

See also

Activity

  1. added this to the NethVoice 1.8 milestone on Dec 2, 2026
  2. added
    nethvoice
    on Dec 2, 2026
  3. added theissue type on Dec 2, 2026
  4. added
    testing
    on Dec 2, 2026
  5. moved this from Todo to Testing in NethVoiceon Dec 2, 2026
  6. edospadoni commented on Dec 2, 2026

    @edospadoni
    MemberAuthor

    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_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:

    runagent -m nethvoice1 podman exec -i mariadb sh -c 'mariadb -uroot -p"$MARIADB_ROOT_PASSWORD" asteriskcdrdb'
    

    Test Case 1 - Update of an existing instance

    • 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

    Testing release: 1.8.8-testing.18 (nethesis/ns8-nethvoice#1374)

    ghcr.io/nethesis/nethvoice:1.8.8-testing.18
    
    api-cli run update-module --data '{"module_url":"ghcr.io/nethesis/nethvoice:1.8.8-testing.18","instances":["nethvoice1"],"force":true}'
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

nethvoicetesting

Type

Projects

  • Status
    Testing

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions