You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2025-03-14 15:29:59

RogerioMax
Member
Registered: 2023-11-28
Posts: 7

"PHP Error (1): Allowed memory size of"

Good morning!

I'm getting this error when trying to perform filters within GLPI that are for long periods or since its beginning. Even changing the PHP Cache to 512M, the problem was not solved. It always says it is in "in /usr/share/glpi/inc/dbmysql.class.php at line 299". Line 299 is "$res = $this->dbh->query($query);"

The function is below

/**
    * Execute a MySQL query
    *
    * @param string $query Query to execute
    *
    * @var array   $CFG_GLPI
    * @var array   $DEBUG_SQL
    * @var integer $SQL_TOTAL_REQUEST
    *
    * @return mysqli_result|boolean Query result handler
    *
    * @throws GlpitestSQLError
    */
   function query($query) {
      global $CFG_GLPI, $DEBUG_SQL, $GLPI, $SQL_TOTAL_REQUEST;

      $is_debug = isset($_SESSION['glpi_use_mode']) && ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE);
      if ($is_debug && $CFG_GLPI["debug_sql"]) {
         $SQL_TOTAL_REQUEST++;
         $DEBUG_SQL["queries"][$SQL_TOTAL_REQUEST] = $query;
      }
      if ($is_debug && $CFG_GLPI["debug_sql"] || $this->execution_time === true) {
         $TIMER                                    = new Timer();
         $TIMER->start();
      }

    $res = $this->dbh->query($query);   
      if (!$res) {
         // no translation for error logs
         $error = "  *** MySQL query error:\n  SQL: ".$query."\n  Error: ".
                   $this->dbh->error."\n";
         $error .= Toolbox::backtrace(false, 'DBmysql->query()', ['Toolbox::backtrace()']);

         Toolbox::logSqlError($error);

         $error_handler = $GLPI->getErrorHandler();
         if ($error_handler instanceof ErrorHandler) {
            $error_handler->handleSqlError($this->dbh->errno, $this->dbh->error, $query);
         }

         if (($is_debug || isAPI()) && $CFG_GLPI["debug_sql"]) {
            $DEBUG_SQL["errors"][$SQL_TOTAL_REQUEST] = $this->error();
         }
      }

      if ($is_debug && $CFG_GLPI["debug_sql"]) {
         $TIME                                   = $TIMER->getTime();
         $DEBUG_SQL["times"][$SQL_TOTAL_REQUEST] = $TIME;
         $DEBUG_SQL['rows'][$SQL_TOTAL_REQUEST] = $this->affectedRows();
      }
      if ($this->execution_time === true) {
         $this->execution_time = $TIMER->getTime(0, true);
      }
      return $res;
   }

We also changed the file /etc/mysql/mariadb.conf.d/50-server.cnf and below, but the error continues. Has anyone seen this problem?

# Enable the slow query log to see queries with especially long duration
#slow_query_log_file    = /var/log/mysql/mariadb-slow.log
#long_query_time        = 10
#log_slow_rate_limit    = 1000
#log_slow_verbosity     = query_plan
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
server-id              = 1
log_bin                = /var/lib/mysql/mysql-bin
expire_logs_days       = 2
max_binlog_size        = 2G
max_binlog_cache_size  = 2G
#binlog_do_db           = include_database_name
#binlog_ignore_db       = exclude_database_name

Offline

#2 2025-03-17 10:58:36

Kaya84
Member
Registered: 2019-06-13
Posts: 228

Re: "PHP Error (1): Allowed memory size of"

Error means that you used all available memory

It's not PHP CACHE or Mysql LOG size related!!

Try increasing PHP memory, but if your db is not huge as I guess, better to do a mysqlcheck on the db.
Check also with php bin/console  if db status is ok.

Offline

Board footer

Powered by FluxBB