Skip to content

Non-persistent MySQL connections are not being closed in Cacti. #11750

Closed as not planned

Description

@elyograg

Description

I have been investigating a problem with Cacti where it opens a new database connection on every 5 minute poll interval, and never closes them, eventually running the DB server out of connections, even with the max_connections set to 1000. It is a new install of Cacti, I am not upgrading.

Eventually I figured out that configuring Cacti to use persistent database connections solved the issue. So there is a workaround.

I am seeing the biggest problem with the long-running daemons, one for cacti itself called cactid, the other for a cacti plugin called flowview. The service for that one is called "flow-capture".

The cacti project is claiming that they have never had to worry about closing connections before and they think something probably changed in PDO.

This is the issue I opened on Cacti for the problem:

Cacti/cacti#5401

PHP Version

PHP 8.1.2-1ubuntu2.13

Operating System

Ubuntu 22.04

Activity

  1. Girgias commented on Jul 21, 2023

    @Girgias
    Member

    That would require bisecting commits, as there have been several changes in PDO but none that I can see which would change that behaviour.

  2. MohamedAbuZamil commented on Aug 3, 2023

    @MohamedAbuZamil
  3. kamil-tekiela commented on Nov 8, 2026

    @kamil-tekiela
    Member

    That sounds like a problem in Cacti code, not in PHP. I don't know what they are doing but they are storing it twice in globals: https://github.com/Cacti/cacti/blob/18500fa313a9f1ee1be48aa111c0eeea001010fa/lib/database.php#L121-L126 and they leak it by reopeninig a new connection https://github.com/Cacti/cacti/blob/18500fa313a9f1ee1be48aa111c0eeea001010fa/lib/database.php#L262-L288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions