FreePBX Crashing Out of Memory

FreePBX 17.0.33.2

Asterisk 22.11.0

Investigating a potential memory leak in one of our FreePBX instance. Overnight we are starting to see daily crashes of the Asterisk service.

We are virtualizing FreePBX on Proxmox and have not seen this issue across our other FreePBX VMs running identical software version/configuration.

VM specs:

  • CPU: 2 cores
  • Memory: 8 GB
  • Storage: 100 GB

Our journalctl shows the following:

Oct 24 11:55:46 dc-prod-pbx01 kernel: out_of_memory+0x1fd/0x4c0
Oct 24 11:55:46 dc-prod-pbx01 kernel: Tasks state (memory values in pages):
Oct 24 11:55:46 dc-prod-pbx01 kernel: Out of memory: Killed process 23390 (asterisk) total-vm:8512928kB, anon-rss:6764080kB, file-rss:0kB, shmem-rss:0kB, UID:999 pgtables:15192kB oom_score_adj:0

We’ve had no issue reports on the Asterisk side for memory leaks like this. The best thing to do would be to isolate the difference between the instance and others. I assume it started after upgrading to 22.11.0?

Are you doing a lot of reloads?

Yes, started around the update to 22.11.0. Only doing a few config changes a day. When the asterisk process crashes, we have to reboot the VM to get it going again.

We have tried increasing memory on the VM to 12 and even 16 GB, and see the VM crashing with same journalctl logs about being out of memory.

Looking at the full asterisk logs around the same time as the memory crash, I don’t see any correlated events around the same time.

Without narrowing it down it’s very much looking for a needle in a haystack…

We have had a few (3) servers that had to be rebooted this morning. I am still trying to track something down. All that I did was upgrade PHP and ran fwconsole ma upgradeall.

Users have also complained of BLF issues, call park/transfer calls disappearing, and no audio when dialing out. Everything was working fine until I did patching/updates on Friday.

Does journalctl show anything on your affected servers about memory issues? This is affecting our largest customer with around 400 extensions. Our other installations have less than 100 extensions.

As I was typing this, our server just crashed again

Oct 26 11:38:17 dc-prod-pbx01 kernel: out_of_memory+0x1fd/0x4c0
Oct 26 11:38:19 dc-prod-pbx01 kernel: Tasks state (memory values in pages):
Oct 26 11:38:19 dc-prod-pbx01 kernel: Out of memory: Killed process 1818 (asterisk) total-vm:9942820kB, anon-rss:5298780kB, file-rss:0kB, shmem-r0

Oct 23 18:12:43 freepbx.sangoma.local kernel: mariadbd invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
Oct 23 18:12:43 freepbx.sangoma.local kernel: oom_kill_process.cold+0xb/0x10
Oct 23 18:12:43 freepbx.sangoma.local kernel: [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
Oct 23 18:12:43 freepbx.sangoma.local kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/freepbx.service,task=asterisk,pid=1576,uid=999
Oct 23 18:12:43 freepbx.sangoma.local kernel: Out of memory: Killed process 1576 (asterisk) total-vm:3041264kB, anon-rss:528464kB, file-rss:0kB, shmem-rss:0kB, UID:999 pgtables:4976kB oom_score_adj:0

Looks like mariadb for me but everrything was fine Friday until I ran fwconsole updates and upgraded PHP.

for us it was qemu-ga over the weekend and today it was bdsecd (Bitdefender) that invoked oom-killer, so mariadb may not be the actual cause

We’re going to do some testing and investigation on the latest Asterisk releases to see if anything sticks out, but details on usage would help.

What info do you need?

Anything? Number of endpoints, number of subscriptions, what you’re doing in FreePBX if anything, applications in use, functionality in use. Difference between a working case and non-working case.

We use Yealink phones, have around 390 PJSIP endpoints across ~8 locations, sites connected via dark fiber back to the datacenter where the server is hosted. We use Endpoint Manager. UCP is running, but rarely used by staff

Only using around 5-10 softphones (MicroSIP). Each location is a school. District admin office and a few departments have ring groups and each building has an auto attendent/IVR that can reach secretary, attendance, counselors, etc.

This server uses a SIP trunk off the provider’s Adtran. Only average 5-10 active calls throughout the day district wide. Mornings and school release are usually busier and we can see 20+ active calls

@packetpusher welcome to the forums. Were there any recent modifications to php.ini ? Any top output you can share to see which process is running away with the memory ?

Asterisk is the process running away with the memory. Running top, you can watch it slowly increase memory utilization. No recent mods to php.ini

image

Started at around 500 MB when the VM restarted. Right before crashing, it was using 6 GB.

You might be able to switch to the certified branch of Asterisk 22 using the asterisk-version-switch command. Not exactly a roll-straight-back but more of a roll-diagonally-back. :face_with_diagonal_mouth:

I can try this this evening. Will that rollback the updates for 22.11.0? My systems seem to crash during the night when there are no users using the system. Before the upgrades, everything was running smooth so something has definitely changed.

Because we are having the server crash during the day, we are going to switch to the certified branch in around 30 minutes after sending out a notice to staff.

Let me know how it goes. Good luck!