Cacti 1.2.24 - Poller.php starves all memory when MariaDB is stopped

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
mbordoni
Posts: 2
Joined: Sun Apr 28, 2024 4:08 am

Cacti 1.2.24 - Poller.php starves all memory when MariaDB is stopped

Post by mbordoni »

To make a backup of my Cacti raspi server I decided to stop mariadb and I found that the server hanged up very soon.
I am using cmd.php as a poller.
After some debugging I found that Poller.php (the second process run from cron) once the mariadb is stopped gets all the cpu and started looping till it consumes all the available memory.

I went to php.in and set a memory_limit but it was no worth.
I went to poller.php itself and I found the following lines of code:
"
/* let PHP only run 1 second longer than the max runtime,
* plus the poller needs lot's of memory
*/
ini_set('max_execution_time', MAX_POLLER_RUNTIME + 1);
ini_set('memory_limit', '-1');
"
and set a limit again
"
/* let PHP only run 1 second longer than the max runtime,
* plus the poller needs lot's of memory
*/
ini_set('max_execution_time', MAX_POLLER_RUNTIME + 1);
ini_set('memory_limit', '1500M');
"

This is a bad design (never allow "no limits" it is not safe). Either set a limit, or remove it and let to use default settings, or, finally, let a config inside cacti configuration to set memory limit accordingly.
After this if someone is able to find the root cause of the loop and memory leak in that situation would be perfect.

Bests,
User avatar
TheWitness
Developer
Posts: 16897
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Cacti 1.2.24 - Poller.php starves all memory when MariaDB is stopped

Post by TheWitness »

Sounds like you've got a php version with a memory leak. It used to be real bad in the php4.x days. Not so much any more.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mbordoni
Posts: 2
Joined: Sun Apr 28, 2024 4:08 am

Re: Cacti 1.2.24 - Poller.php starves all memory when MariaDB is stopped

Post by mbordoni »

BTW: I am using PHP 8.2.18 on a raspi with Debian bookworm.

The design flaw is really in poller.php that has the setting to allow infinite memory consumption.
NEVER DO THIS, IT IS IT HARAKIRI!

For the root cause I think it is due to something about the permanent db connection end the related pooling that cannot understand if and when db goes down.

If you put a big at will amount of memory in the setting at most the process is killed and this prevents the server from hanging up.

In my case when I start the backup procedure I stop cron, apache and mariadb processes and in case this process ends is a good way to proceed since at the end of backup by starting the 3 services I will get it back on via cron scheduling.
User avatar
TheWitness
Developer
Posts: 16897
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Cacti 1.2.24 - Poller.php starves all memory when MariaDB is stopped

Post by TheWitness »

Upgrade to 1.2.27 as soon as it's out. That may not be the solution, but there were some light design changes between releases. Also, check for a memory leak in PHP. Check the php-fpm and apache processes over time. You may need to reduce the default servers and threads in the apache config on small machines like a Rasberry Pi. Take a look at this article, and then update for your version of Apache:

https://serverfault.com/questions/77585 ... oncurrency

Tips:

Minimize Servers
Reduce Lifetime of any process (as they will accumulate memory in cache)
Minimize Threads

But, keep an eye on the Cactid service (if you are running it).

I hope this helps.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests