Fuel Cms creates many database process in sleep state

edited October 2023 in Bug Reports

Im new to Fuel CMS, Just want to ask what does this code below do it's in line 158 - 161 of C:\laragon\www\fuel\fuel\modules\fuel\core\MY_Model.php file. Because it seems like the empty($this->db) will always be true because If I check the value of $this->db it always NULL. I have many models called in my Home Page and it seems like this code below creates many mysql database connection that in sleep state. If I delete that code the unwanted mysql connections is gone and still my website is working properly.

                    // starting this code
        if (empty($this->db))
        {
            $this->load->database($this->dsn);
        }
                    // to this code
        $CI =& get_instance();
        if (isset($CI->db))
        {
            // create a copy of the DB object to prevent cross model interference
            unset($this->db);
            $db = clone $CI->db;
            $this->set_db($db);
        }
        else
        {
            $CI->load->language('db');
            show_error(lang('db_unable_to_connect'));
        }

Comments

  • There is a "dsn" property on a model that can be set for rare cases when the model's data pulls from a different database. If it's empty, it just uses the default database connection. How are you determining the number of connections in a sleep state (is there a query you run)?

  • Im just running SHOW PROCESSLIST command in my phpmyadmin. is it ok to delete that code? because it seems my project is working perfectly fine even if I commented it

  • edited October 2023

    Sometimes we're having "Too many connections" error in codeigniter and we found out that code in our projects creates many connections in database.

  • Thanks for the report. I've pushed that fix to the develop branch here if you want to merge it in.
    https://github.com/daylightstudio/FUEL-CMS/commit/6454106579710bf4df20a5fbd1d9a642c495d095

  • Ok thank you very much :)

Sign In or Register to comment.